Guy Steele | 23 May 19:04

Re: Juxtaposition for string concatenation with implicit conversion

In response to feedback from several people, I have now revised
my proposal.  See below.

On May 23, 2008, at 10:28 AM, Victor Luchangco wrote:

> In a recent meeting, we discussed the merits and pitfalls of using  
> juxtaposition for string concatenation, and I think there was  
> sentiment against it, but we deferred decision on it.  Here's an  
> example that we might consider in making this decision:
>
> run(args) = do
>  x = 3
>  y = 2
>  println x y
>  println x y "4"
>  println "4" x y
> end
>
> By the way, this example is similar to the Visual Basic program we  
> give as an example of how coercion can be confusing in the coercion  
> paper.
>
> - Victor

Yes, this is an issue, but my new proposal below addresses this.
Changes are indicated by <add></add> and <delete></delete>.

REVISED PROPOSAL:

Define infix || to be straightforward string concatenation.  Thus the
(Continue reading)

Victor Luchangco | 2 Jun 16:20

Re: Juxtaposition for string concatenation with implicit conversion

A few comments:

On May 23, 2008, at 1:04 PM, Guy Steele wrote:

> REVISED PROPOSAL:
>
> Define infix || to be straightforward string concatenation.  Thus the
> value of either  "foo"||"bar"  or  "foo" || "bar"  would be   
> "foobar" .
>
> Change juxtaposition of strings so that it concatenates
> with a space in between <add>unless either of the operand
> strings is empty, in which case no space is added</add>;
> that is, the value of  "foo" "bar"  would be  "foo bar" .
> <add> The value of either  "foo" ""  or  "" "foo"  would be "foo",
> and the value of  "" ""  would be  "" .</add>  (Normally one uses
> loose juxtaposition in notating string concatenation, so the visual
> intuition is that the quotes disappear but the space between
> remains in the result.)  Thus if  x  and  y  are strings,
> then  x y  produces the same result as  <delete> x||" "||y </delete>
> <add> if x = "" then y elif y = "" then x else x||" "||y end </add> .
> Define the infix operator ||| to do the same thing as juxtaposition.

I would prefer that we define ||| and then juxtaposition in terms of  
|||, so that a programmer who doesn't want juxtaposition to do string  
concatenation can just redefine juxtaposition and still have the |||  
operator.

> Define the operator // to be a prefix, postfix, and infix
> operator on strings.  As a prefix operator, it prepends
(Continue reading)

Jan-Willem Maessen | 2 Jun 23:29

Re: Juxtaposition for string concatenation with implicit conversion

Just a status report on incorporating this proposal into the libraries.

On May 23, 2008, at 1:04 PM, Guy Steele wrote:

> In response to feedback from several people, I have now revised
> my proposal.  See below.

> REVISED PROPOSAL:
>
> Define infix || to be straightforward string concatenation.  Thus the
> value of either  "foo"||"bar"  or  "foo" || "bar"  would be   
> "foobar" .

This has been implemented and passes the tests.  It performs string  
conversion.  For the moment juxtaposition is defined as || until I can  
convert all instances of string juxtaposition in our code to use the  
new convention.  I want to implement and test the new behavior first.

Changing the behavior of juxtaposition will cause massive upheaval and  
will be a separate step.  It may not happen for a long time due to  
lack of my time.

> Change juxtaposition of strings so that it concatenates
> with a space in between <add>unless either of the operand
> strings is empty, in which case no space is added</add>;
> that is, the value of  "foo" "bar"  would be  "foo bar" .
> <add> The value of either  "foo" ""  or  "" "foo"  would be "foo",
> and the value of  "" ""  would be  "" .</add>  (Normally one uses
> loose juxtaposition in notating string concatenation, so the visual
> intuition is that the quotes disappear but the space between
(Continue reading)


Gmane