Looking for thoughts: Append collections with objects

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
21 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Looking for thoughts: Append collections with objects

Michael Lucas-Smith-2
I'm looking for some feedback on an API that has been proposed for appending collections with non-collections. So let me describe the desired behavior:

#(1) & 2 -> #(1 2)
#(1) & #(2) -> #(1 2)
1 & #(2) -> #(1 2) * note 1
1 & 2 -> #(1 2)
#a & #b -> #(#a #b) * note 2

note 1: the #& api is based off of ScriptingSupport which does not produce this result, instead it gives you #(1 #(2))
note 2: the #, api in Smalltalk-80 would produce 'ab'

First question: Do you desire this kind of behavior?
        Sub question 1: Where do you use this kind of behavior?
        Sub question 2: Have you implemented this in your own libraries?
        Sub question 3: You hate it, why?

Second question: What do you think of using #& for this kind of behavior?
        Sub question 1: Do you have another suggested binary selector?


My thoughts on the subject: I find this approach to appending much more convenient when doing scripting. I also think #& might be a bad choice as we'd never be able to create collections from booleans. Perhaps /\ to append two objects and \/ to create a set from two objects. I saw /\ and \/ used as binary operations in Slate and thought it was quite an interesting use.

Michael
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Looking for thoughts: Append collections with objects

Michael Lucas-Smith-2

On Feb 15, 2011, at 3:17 PM, Michael Lucas-Smith wrote:

I'm looking for some feedback on an API that has been proposed for appending collections with non-collections. So let me describe the desired behavior:

#(1) & 2 -> #(1 2)
#(1) & #(2) -> #(1 2)
1 & #(2) -> #(1 2) * note 1
1 & 2 -> #(1 2)
#a & #b -> #(#a #b) * note 2

note 1: the #& api is based off of ScriptingSupport which does not produce this result, instead it gives you #(1 #(2))
note 2: the #, api in Smalltalk-80 would produce 'ab'

First question: Do you desire this kind of behavior?
Sub question 1: Where do you use this kind of behavior?
Sub question 2: Have you implemented this in your own libraries?
Sub question 3: You hate it, why?

Second question: What do you think of using #& for this kind of behavior?
Sub question 1: Do you have another suggested binary selector?


My thoughts on the subject: I find this approach to appending much more convenient when doing scripting. I also think #& might be a bad choice as we'd never be able to create collections from booleans. Perhaps /\ to append two objects and \/ to create a set from two objects. I saw /\ and \/ used as binary operations in Slate and thought it was quite an interesting use.


Having thought slightly longer than a few seconds and remembering I'd done something similar to this before:
\/ would be a union (∪)
/\ would be an intersection (∩)


Michael





(slightly side discussion: I have a published package called FastMerge in public store. It allowed a fast merge as a union or intersection for multiple arrays at once (for the case of an intersection, you got the results back as a ranked collection).

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Looking for thoughts: Append collections with objects

Joerg Beekmann, DeepCove Labs (YVR)
> 1 & #(2) -> #(1 2)

so presumably #(2) & 1 -> #(2 1) ?


From: [hidden email] [mailto:[hidden email]] On Behalf Of Michael Lucas-Smith
Sent: Tuesday, February 15, 2011 3:41 PM
To: vwnc
Subject: Re: [vwnc] Looking for thoughts: Append collections with objects


On Feb 15, 2011, at 3:17 PM, Michael Lucas-Smith wrote:


I'm looking for some feedback on an API that has been proposed for appending collections with non-collections. So let me describe the desired behavior:

#(1) & 2 -> #(1 2)
#(1) & #(2) -> #(1 2)
1 & #(2) -> #(1 2) * note 1
1 & 2 -> #(1 2)
#a & #b -> #(#a #b) * note 2

note 1: the #& api is based off of ScriptingSupport which does not produce this result, instead it gives you #(1 #(2))
note 2: the #, api in Smalltalk-80 would produce 'ab'

First question: Do you desire this kind of behavior?
        Sub question 1: Where do you use this kind of behavior?
        Sub question 2: Have you implemented this in your own libraries?
        Sub question 3: You hate it, why?

Second question: What do you think of using #& for this kind of behavior?
        Sub question 1: Do you have another suggested binary selector?


My thoughts on the subject: I find this approach to appending much more convenient when doing scripting. I also think #& might be a bad choice as we'd never be able to create collections from booleans. Perhaps /\ to append two objects and \/ to create a set from two objects. I saw /\ and \/ used as binary operations in Slate and thought it was quite an interesting use.

Having thought slightly longer than a few seconds and remembering I'd done something similar to this before:
        \/ would be a union (∪)
        /\ would be an intersection (∩)


Michael





(slightly side discussion: I have a published package called FastMerge in public store. It allowed a fast merge as a union or intersection for multiple arrays at once (for the case of an intersection, you got the results back as a ranked collection).

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Looking for thoughts: Append collections with objects

Michael Lucas-Smith-2

On Feb 15, 2011, at 4:33 PM, Joerg Beekmann, DeepCove Labs wrote:

>> 1 & #(2) -> #(1 2)
>
> so presumably #(2) & 1 -> #(2 1) ?

Yes, it wouldn't sort for you.
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Looking for thoughts: Append collections with objects

davidbuck
In reply to this post by Michael Lucas-Smith-2
The idea is interesting but don't use #& as the selector since it interferes with boolean operations. You want a selector that's not implemented anywhere else in the system to get consistent behavior.

David Buck

Sent from my BlackBerry device on the Rogers Wireless Network

-----Original Message-----
From: Michael Lucas-Smith <[hidden email]>
Sender: [hidden email]
Date: Tue, 15 Feb 2011 15:41:00
To: vwnc<[hidden email]>
Subject: Re: [vwnc] Looking for thoughts: Append collections with objects

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc



_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Looking for thoughts: Append collections with objects

Andres Valloud-6
In reply to this post by Michael Lucas-Smith-2
The message #& seems like a contraction of copyWith: to me.  Too bad one
can't use the selector #'w/' or some such.

On 2/15/2011 3:17 PM, Michael Lucas-Smith wrote:

> I'm looking for some feedback on an API that has been proposed for appending collections with non-collections. So let me describe the desired behavior:
>
> #(1)&  2 ->  #(1 2)
> #(1)&  #(2) ->  #(1 2)
> 1&  #(2) ->  #(1 2) * note 1
> 1&  2 ->  #(1 2)
> #a&  #b ->  #(#a #b) * note 2
>
> note 1: the #&  api is based off of ScriptingSupport which does not produce this result, instead it gives you #(1 #(2))
> note 2: the #, api in Smalltalk-80 would produce 'ab'
>
> First question: Do you desire this kind of behavior?
> Sub question 1: Where do you use this kind of behavior?
> Sub question 2: Have you implemented this in your own libraries?
> Sub question 3: You hate it, why?
>
> Second question: What do you think of using #&  for this kind of behavior?
> Sub question 1: Do you have another suggested binary selector?
>
>
> My thoughts on the subject: I find this approach to appending much more convenient when doing scripting. I also think #&  might be a bad choice as we'd never be able to create collections from booleans. Perhaps /\ to append two objects and \/ to create a set from two objects. I saw /\ and \/ used as binary operations in Slate and thought it was quite an interesting use.
>
> Michael
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Looking for thoughts: Append collections with objects

Eliot Miranda-2
In reply to this post by davidbuck


On Tue, Feb 15, 2011 at 6:11 PM, David Buck <[hidden email]> wrote:
The idea is interesting but don't use #& as the selector since it interferes with boolean operations. You want a selector that's not implemented anywhere else in the system to get consistent behavior.

Agreed.  I suggest ,, for something symmetrical or ,+ and +, for something assymetric.  e.g. 1 +, 'seq' => #(1 $s $e $q), 'seq' ,+ 1 => #($s $e $q 1), but both 1 ,+ 'seq' and 'seq' +, 1 raise an error.  ,, is reminiscent of , which we're used to using for concatenation.  The advantage that the assymmetric forms have is disambiguation.  #sym ,+ #sym => #($s $y $m #sym).  If you want to concatenate two sequences you can already use ,.

best
Eliot


David Buck

Sent from my BlackBerry device on the Rogers Wireless Network

-----Original Message-----
From: Michael Lucas-Smith <[hidden email]>
Sender: [hidden email]
Date: Tue, 15 Feb 2011 15:41:00
To: vwnc<[hidden email]>
Subject: Re: [vwnc] Looking for thoughts: Append collections with objects

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc



_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Looking for thoughts: Append collections with objects

Terry Raymond
In reply to this post by Michael Lucas-Smith-2
Given the limited number of single character operators why
not use double character operators. That way there would be
less confusion with overloading the meaning of existing operators.

Terry
 
===========================================================
Terry Raymond
Crafted Smalltalk
80 Lazywood Ln.
Tiverton, RI  02878
(401) 624-4517      [hidden email]
<http://www.craftedsmalltalk.com>
===========================================================

> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On Behalf Of Michael Lucas-Smith
> Sent: Tuesday, February 15, 2011 6:17 PM
> To: vwnc
> Subject: [vwnc] Looking for thoughts: Append collections with objects
>
> I'm looking for some feedback on an API that has been proposed for appending collections with non-
> collections. So let me describe the desired behavior:
>
> #(1) & 2 -> #(1 2)
> #(1) & #(2) -> #(1 2)
> 1 & #(2) -> #(1 2) * note 1
> 1 & 2 -> #(1 2)
> #a & #b -> #(#a #b) * note 2
>
> note 1: the #& api is based off of ScriptingSupport which does not produce this result, instead it
> gives you #(1 #(2))
> note 2: the #, api in Smalltalk-80 would produce 'ab'
>
> First question: Do you desire this kind of behavior?
> Sub question 1: Where do you use this kind of behavior?
> Sub question 2: Have you implemented this in your own libraries?
> Sub question 3: You hate it, why?
>
> Second question: What do you think of using #& for this kind of behavior?
> Sub question 1: Do you have another suggested binary selector?
>
>
> My thoughts on the subject: I find this approach to appending much more convenient when doing
> scripting. I also think #& might be a bad choice as we'd never be able to create collections from
> booleans. Perhaps /\ to append two objects and \/ to create a set from two objects. I saw /\ and \/
> used as binary operations in Slate and thought it was quite an interesting use.
>
> Michael
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Looking for thoughts: Append collections with objects

davidbuck
In reply to this post by davidbuck
What would happen in the following cases (assuming #& as the selector):

#(1 2) & 'hello'

'Hello' & 'there'

Array new & 'hello'

#[1 2] & 'hello'

Set new & 'hello'

'Hello' & Set new

It's hard to imagine a consistent answer to all of these.

David Buck

Sent from my BlackBerry device on the Rogers Wireless Network

-----Original Message-----
From: "David Buck" <[hidden email]>
Sender: [hidden email]
Date: Wed, 16 Feb 2011 02:11:14
To: Michael Lucas-Smith<[hidden email]>; <[hidden email]>; vwnc<[hidden email]>
Reply-To: [hidden email]
Subject: Re: [vwnc] Looking for thoughts: Append collections with objects

The idea is interesting but don't use #& as the selector since it interferes with boolean operations. You want a selector that's not implemented anywhere else in the system to get consistent behavior.

David Buck

Sent from my BlackBerry device on the Rogers Wireless Network

-----Original Message-----
From: Michael Lucas-Smith <[hidden email]>
Sender: [hidden email]
Date: Tue, 15 Feb 2011 15:41:00
To: vwnc<[hidden email]>
Subject: Re: [vwnc] Looking for thoughts: Append collections with objects

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc



_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Looking for thoughts: Append collections with objects

Michael Lucas-Smith-2


On 15 February 2011 19:56, David Buck <[hidden email]> wrote:
What would happen in the following cases (assuming #& as the selector):

#(1 2) & 'hello'
#(1 2 'hello') 

'Hello' & 'there'
#('Hello' 'there') 

Array new & 'hello'
#('hello') 

#[1 2] & 'hello'
#(1 2 'hello') 

Set new & 'hello'
(Set with: 'hello') <- this may be a mistake 

'Hello' & Set new
#('Hello') 

It's hard to imagine a consistent answer to all of these.

The contract is technically "Return a collection that isn't a string". #, would still be the method to use if you want to concatenate.

Michael


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Looking for thoughts: Append collections with objects

Reinout Heeck-2
In reply to this post by Eliot Miranda-2
On 2/16/2011 4:11 AM, Eliot Miranda wrote:
> I suggest ,, for something symmetrical or ,+ and +, for something
> assymetric.

I agree with Eliot that the various combinations should be treated
/explicitly/.
However I think we will need four selectors so we can disambiguate the
following:


'seq' , 'seq'  = 'seqseq'

'seq' ,, 'seq' = #( 'seq' 'seq' )



>  e.g. 1 +, 'seq' => #(1 $s $e $q), 'seq' ,+ 1 => #($s $e $q 1), but
> both 1 ,+ 'seq' and 'seq' +, 1 raise an error.  ,, is reminiscent of ,
> which we're used to using for concatenation.  The advantage that the
> assymmetric forms have is disambiguation.  #sym ,+ #sym => #($s $y $m
> #sym).  If you want to concatenate two sequences you can already use ,.
>
> best
> Eliot



Reinout
-------

--
*********************************************************************

Dit e-mailbericht is alleen bestemd voor de geadresseerde(n).

Gebruik door anderen is niet toegestaan. Indien u niet degeadresseerde(n) bent wordt u verzocht de verzender hiervan op de hoogte te stellen en het bericht te verwijderen. Door de elektronische verzending kunnen aan de inhoud van dit bericht geen rechten worden ontleend.

Soops B.V. is gevestigd te Amsterdam, Nederland, en is geregistreerd bij de Kamer van Koophandel onder nummer 33240368.
Soops B.V. levert volgens de Fenit voorwaarden, gedeponeerd te Den Haag op 8 december 1994 onder nummer 1994/189.
**********************************************************************

This e-mail message is intended to be exclusively for the addressee.

If you are not the intended recipient you are kindly requested not to make any use whatsoever of the contents and to notify the sender immediately by returning this e-mail message. No rights can be derived from this message.

Soops B.V. is a private limited liability company and has its seat at Amsterdam, The Netherlands and is registered with the Trade Registry of the Chamber of Commerce and Industry under number 33240368.
Soops B.V. delivers according to the General Terms and Conditions of Business of Fenit, registered at The Hague, The Netherlands on December 8th, 1994, under number 1994/189
**********************************************************************


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Looking for thoughts: Append collections with objects

Steven Kelly
In reply to this post by Michael Lucas-Smith-2

I’ve only ever felt the need for this with the case where I’m adding a single character to a string:

'foobar' & myCharacter    -> 'foobarX'

 

In the cases you show, e.g. myArray & myElement, I wouldn’t be using an array if I wanted to extend it – I’d just use myOrderedCollection add: myElement

 

I’d agree with Eliot that having a symmetric “collection OP element” and “element OP collection” may not give intuitive results. The root problem is that arrays can happily contain arrays and other collections. Your note 1 and note 2 show that there is more than one expected result for those cases. On the other hand, I don’t like the look of #+, or #,+ and I doubt I could remember which was which, given that I don’t need them much.

 

I agree with others that #& isn’t a good choice: it’s understood to be commutative and associative, and to have both LHS and RHS of the same type.

 

Overall, my vote would be that general collections don’t need this (use variable-sized collections instead), but that it would be nice for adding a character to a string, to shorten “myString , (String with: myCharacter)” (which I prefer to #copyWith: as it is simpler when concatenating several things at once). Is there any problem extending #, to accept a non-collection argument, and maybe even a non-collection receiver? Exceptions already use #, like that.

 

'foo' , 'bar' => 'foobar'

'foo' , $b => 'foob'

$b , 'foo' => 'bfoo'

$b, $c => 'bc'

 

This is easily accomplished with three little methods (attached, admittedly only briefly tested).

 

Steve

 

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Michael Lucas-Smith
Sent: 16. helmikuuta 2011 1:41
To: vwnc
Subject: Re: [vwnc] Looking for thoughts: Append collections with objects

 

 

On Feb 15, 2011, at 3:17 PM, Michael Lucas-Smith wrote:



I'm looking for some feedback on an API that has been proposed for appending collections with non-collections. So let me describe the desired behavior:

#(1) & 2 -> #(1 2)
#(1) & #(2) -> #(1 2)
1 & #(2) -> #(1 2)                  * note 1
1 & 2 -> #(1 2)
#a & #b -> #(#a #b)   * note 2

note 1: the #& api is based off of ScriptingSupport which does not produce this result, instead it gives you #(1 #(2))
note 2: the #, api in Smalltalk-80 would produce 'ab'

First question: Do you desire this kind of behavior?
          Sub question 1: Where do you use this kind of behavior?
          Sub question 2: Have you implemented this in your own libraries?
          Sub question 3: You hate it, why?

Second question: What do you think of using #& for this kind of behavior?
          Sub question 1: Do you have another suggested binary selector?


My thoughts on the subject: I find this approach to appending much more convenient when doing scripting. I also think #& might be a bad choice as we'd never be able to create collections from booleans. Perhaps /\ to append two objects and \/ to create a set from two objects. I saw /\ and \/ used as binary operations in Slate and thought it was quite an interesting use.

 

Having thought slightly longer than a few seconds and remembering I'd done something similar to this before:

          \/ would be a union ()

          /\ would be an intersection (∩)

 

 

Michael

 

 

 

 

 

(slightly side discussion: I have a published package called FastMerge in public store. It allowed a fast merge as a union or intersection for multiple arrays at once (for the case of an intersection, you got the results back as a ranked collection).


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

CommaForCharacter.st (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Looking for thoughts: Append collections with objects

Holger Guhl
In reply to this post by Michael Lucas-Smith-2
  My answer on the 1st question: No I do not desire this kind of behavior.
I write my programs in a different way, with much more concentration on readability. In particular,
I want to express the difference between a collection instance and a non-collection thing. Your
examples are of course simplifying, in a real program the arguments will be variables. The proposed
protocol will blur the picture, because everything is accepted and processed somehow.
Thanks for asking Subquestion 3.
Yes, I hate it, because it's yet another example of undesired polymorphism and superfluous
operation. I don't see the benefit of #& over #copyWith: or #,. The biggest disadvantage is that it
makes life harder when you need to see senders of certain methods.
With this new operator, arrays are capable of Boolean logic. This is consistent after telling
Filename how to do division ( #/ alias #construct: ). Now if you want to check out where your
program creates a given Filename you have the pleasure to check senders of #/ as well, and have a
nice time to strip off those few cases where Numbers are involved. No fear, that's 275 methods only,
in an image with nothing in but Store.
Well, there are only 157 senders of #& . Negligible? Let's regard unsharp senders result lists as
occasion to get to know more methods in VisualWorks...

Another point, adding to my "I do not need this behavior". A major part of errors in my programs
is/was bad handling of collections and non-collections. I guess that everybody knows the bug where
an argument is expected a collection, but isn't (and vice versa). In those situations, I never had
the impression that VisualWorks should have the proposed behavior to help me write better code. Far
from being helpful, it could increase the problems by simply hiding or deferring error detection.

Last not least: Performance! Of course, everybody has in his own hands to use the proposed operators
with discipline. But compare with #, (comma) for concatenating collections. We have an extra Code
Critics rule to alert over-use, because it's easily written and costly in time and memory
consumption. No discussion about "a & b", but binary operators suggest coding like "a & b & c & ..."
because there is nothing to stop the flow of typing.

Cheers

Holger Guhl
--
Senior Consultant * Certified Scrum Master * [hidden email]
Tel: +49 231 9 75 99 21 * Fax: +49 231 9 75 99 20
Georg Heeg eK Dortmund
Handelsregister: Amtsgericht Dortmund  A 12812



Am 16.02.2011 00:17, schrieb Michael Lucas-Smith:

> I'm looking for some feedback on an API that has been proposed for appending collections with non-collections. So let me describe the desired behavior:
>
> #(1)&  2 ->  #(1 2)
> #(1)&  #(2) ->  #(1 2)
> 1&  #(2) ->  #(1 2) * note 1
> 1&  2 ->  #(1 2)
> #a&  #b ->  #(#a #b) * note 2
>
> note 1: the #&  api is based off of ScriptingSupport which does not produce this result, instead it gives you #(1 #(2))
> note 2: the #, api in Smalltalk-80 would produce 'ab'
>
> First question: Do you desire this kind of behavior?
> Sub question 1: Where do you use this kind of behavior?
> Sub question 2: Have you implemented this in your own libraries?
> Sub question 3: You hate it, why?
>
> Second question: What do you think of using #&  for this kind of behavior?
> Sub question 1: Do you have another suggested binary selector?
>
>
> My thoughts on the subject: I find this approach to appending much more convenient when doing scripting. I also think #&  might be a bad choice as we'd never be able to create collections from booleans. Perhaps /\ to append two objects and \/ to create a set from two objects. I saw /\ and \/ used as binary operations in Slate and thought it was quite an interesting use.
>
> Michael
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwn
>
>
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Looking for thoughts: Append collections with objects

Ralph Johnson
In reply to this post by Michael Lucas-Smith-2
I like the fact that we have nextPut: and nextPutAll: for writing to
streams.   It always takes new Smalltalkers a little time to get this,
but in fact a character is not just a collection of characters of size
1.   At least, in Smalltalk it is not.

I would rather have two different operations for concatenating two
collections and concatenating an object to a collection.    Since we
use #, for the first, I think #,, for the second would be fine, though
in hindsight Smalltalk should have used #,, for collections and #, for
a single object.  It is too late now, though.

I'd prefer to have less special string protocol, not more.  I always
liked the fact that all those methods in SequentiableCollection worked
as well for arrays as they did for strings.  But it you are going to
have non-standard behavior for a standard operation like
concatenation, it is better to localize it to a single class.

-Ralph
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Looking for thoughts: Append collections with objects

Dennis smith-4
In reply to this post by Holger Guhl
My own personal feeling is that this just gets confusing.  We already
have ways to
do what is suggested, and the added non-intuitive polymorphism could
just lead to
confusion.

I had added the ability for #, for strings to take a character as the
parameter, but
I never think to use it -- so I could probably remove it now.

Other than that, I don't see the overpowering need that would make the extra
complexity worthwhile.

--
Dennis Smith                         +1 416.798.7948
Cherniak Software Development Corporation   Fax: +1 416.798.0948
509-2001 Sheppard Avenue East        [hidden email]
Toronto, ON M2J 4Z8              sip:[hidden email]
Canada         http://www.CherniakSoftware.com
Entrance off Yorkland Blvd south of Sheppard Ave east of the DVP

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Looking for thoughts: Append collections with objects

Boris Popov, DeepCove Labs (SNN)
Michael,

I can't say an immediate use case strikes me for this kind of API, but
perhaps seeing some real-life examples where you felt a need for it
would help me see the light? There's always that option of just making
this part of third-party package and wait for wider adoption (if it
comes) to warrant inclusion in base, just like #cull: and similar things
got integrated?

-Boris

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On
Behalf Of Dennis Smith
Sent: Wednesday, February 16, 2011 8:33 AM
To: [hidden email]
Subject: Re: [vwnc] Looking for thoughts: Append collections with
objects

My own personal feeling is that this just gets confusing.  We already
have ways to do what is suggested, and the added non-intuitive
polymorphism could just lead to confusion.

I had added the ability for #, for strings to take a character as the
parameter, but I never think to use it -- so I could probably remove it
now.

Other than that, I don't see the overpowering need that would make the
extra complexity worthwhile.

--
Dennis Smith                         +1 416.798.7948
Cherniak Software Development Corporation   Fax: +1 416.798.0948
509-2001 Sheppard Avenue East        [hidden email]
Toronto, ON M2J 4Z8              sip:[hidden email]
Canada         http://www.CherniakSoftware.com
Entrance off Yorkland Blvd south of Sheppard Ave east of the DVP

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Looking for thoughts: Append collections with objects

Niall Ross
In reply to this post by Reinout Heeck-2
collectionOfThoseWhoAgree  := 'Michael' ,, 'Eliot' ,, 'Reinout'.

collectionOfThoseWhoAgree ,+ 'Niall'

Or
    'Niall' +, collectionOfThoseWhoAgree
to give myself my proper priority. :-)

Maybe this will replace
    +1
in emails. :-)

Reinout wrote:

>On 2/16/2011 4:11 AM, Eliot Miranda wrote:
>  
>
>>I suggest ,, for something symmetrical or ,+ and +, for something
>>assymetric.
>>    
>>
>
>I agree with Eliot that the various combinations should be treated
>/explicitly/.
>However I think we will need four selectors so we can disambiguate the
>following:
>
>
>'seq' , 'seq'  = 'seqseq'
>
>'seq' ,, 'seq' = #( 'seq' 'seq' )
>
>
>
>  
>
>> e.g. 1 +, 'seq' => #(1 $s $e $q), 'seq' ,+ 1 => #($s $e $q 1), but
>>both 1 ,+ 'seq' and 'seq' +, 1 raise an error.  ,, is reminiscent of ,
>>which we're used to using for concatenation.  The advantage that the
>>assymmetric forms have is disambiguation.  #sym ,+ #sym => #($s $y $m
>>#sym).  If you want to concatenate two sequences you can already use ,.
>>
>>best
>>Eliot
>>    
>>
>
>
>
>Reinout
>-------
>
>  
>


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Looking for thoughts: Append collections with objects

Reinout Heeck-2
On 2/16/2011 3:16 PM, Niall Ross wrote:

> collectionOfThoseWhoAgree  := 'Michael' ,, 'Eliot' ,, 'Reinout'.
>
> collectionOfThoseWhoAgree ,+ 'Niall'
>
> Or
>    'Niall' +, collectionOfThoseWhoAgree
> to give myself my proper priority. :-)
>
> Maybe this will replace
>    +1
> in emails. :-)

No real need for this list,
   +1
is simply Newspeak (or Self for old farts)

:-)


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Looking for thoughts: Append collections with objects

John Brant-2
In reply to this post by Michael Lucas-Smith-2
On 2/15/2011 5:17 PM, Michael Lucas-Smith wrote:
> Sub question 1: Where do you use this kind of behavior?

In my image, I have ~85K methods. There are ~125 methods with #copyWith:
sends and ~480 that send #, where the receiver or argument isn't
obviously a string. I used the following search rule:

--------------------
`{:node | ((node isKindOf: RBLiteralNode) and: [node value isKindOf:
String]) not and: [((node isKindOf: RBMessageNode) and: [#(printString
storeString , withCRs) includes: node selector]) not]}
        ,
`{:node | ((node isKindOf: RBLiteralNode) and: [node value isKindOf:
String]) not and: [((node isKindOf: RBMessageNode) and: [#(printString
storeString , withCRs) includes: node selector]) not]}
--------------------

If you look at these, there are still several that are strings and
others that exceptions.


> Sub question 2: Have you implemented this in your own libraries?

No.

> Sub question 3: You hate it, why?

First, the #& selector doesn't work due to Boolean>>&. Furthermore, I
would bet that there are several customers that have created Integer>>&
to be #bitAnd: (like is done in VAST). Therefore, any uses that you use
in the base product that uses Integers would be broken by the customer's
definition of Integer>>&. Second, given my analysis above, it doesn't
seem to be that common -- 0.7% of the methods may have a use for it.
Third, it doesn't clearly define the special cases. For example, you say
strings are special, but what about ByteArray? I can argue that they
should be like strings or like other collections. Fourth, it is
generally better to use streams (or OrderedCollections) for lots of
concatenations. If this was widely used, it might lead to more of the
Smalltalk is slow talk due to O(n^2) concatenation instead of O(n)
streaming/OrderedCollections. Finally, we are using Smalltalk. If I want
to define a special selector to do this, I can do it myself. I don't
need the vendor to do it for me.


John Brant
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Thanks Re: Append collections with objects

Michael Lucas-Smith-2
In reply to this post by Michael Lucas-Smith-2
Thank you everyone for your feedback. It has convinced me that it's not worthwhile seeking an addition to the base for a protocol quite like this at this time (or possibly any time).

Some of the suggestions are really interesting though and I'll be looking at trying them out in ScriptingSupport down the road.

Michael

On Feb 15, 2011, at 3:17 PM, Michael Lucas-Smith wrote:

> I'm looking for some feedback on an API that has been proposed for appending collections with non-collections. So let me describe the desired behavior:
>
> #(1) & 2 -> #(1 2)
> #(1) & #(2) -> #(1 2)
> 1 & #(2) -> #(1 2) * note 1
> 1 & 2 -> #(1 2)
> #a & #b -> #(#a #b) * note 2
>
> note 1: the #& api is based off of ScriptingSupport which does not produce this result, instead it gives you #(1 #(2))
> note 2: the #, api in Smalltalk-80 would produce 'ab'
>
> First question: Do you desire this kind of behavior?
> Sub question 1: Where do you use this kind of behavior?
> Sub question 2: Have you implemented this in your own libraries?
> Sub question 3: You hate it, why?
>
> Second question: What do you think of using #& for this kind of behavior?
> Sub question 1: Do you have another suggested binary selector?
>
>
> My thoughts on the subject: I find this approach to appending much more convenient when doing scripting. I also think #& might be a bad choice as we'd never be able to create collections from booleans. Perhaps /\ to append two objects and \/ to create a set from two objects. I saw /\ and \/ used as binary operations in Slate and thought it was quite an interesting use.
>
> Michael


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
12