Hi, Squeak and I expect Pharo have the ability to create arrays by putting a bunch of Smalltalk code between {} similar to #() for constants. I think this is some syntactic sugar to create the late bound array. For example: {Date today. Time now} will create a two element array with the todays date in the first element and the current time in the second. There are times when I think this would be very useful. Does VA Smalltalk have this feature? If it does I've missed it. Any chance of it being added to VA Smalltalk? I don't know if the Seaside code uses this. If it doesn't it could in the future. Is this a good thing to add to VA Smalltalk or is it too different from the normal syntax? Lou
-- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/groups/opt_out. |
Lou - Yes, Squeak and Pharo both use #{ } to create dynamic arrays. For readers who are not familiar with dynamic arrays, your example of #{Date today. Time now} is equivalent to Array with: Date today with: Time now. Can you give some examples of "...times when I think this would be very useful"? VA Smalltalk does not support the #{ } syntax; Seaside does not (and will not) use the #{ } syntax because it is not portable across Smalltalk platforms; we have no current plans to implement the #{ } form of creating arrays. John On Wednesday, July 10, 2013 4:28:52 PM UTC-4, Louis LaBrunda wrote: -- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/groups/opt_out. |
Hi John, I did say "...times when I think this would be very useful" didn't I, that was probably too strong. I guess when I'm feeling terse, it would be a nice to have and would look neater than "Array with:...". Given that it is not widely supported and would require a compiler change and not just some new methods, I think it is not worth the effort. Thanks anyway. Lou -- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/groups/opt_out. |
In reply to this post by John O'Keefe-3
On Thursday, 11 July 2013 07:54:05 UTC-7, John O'Keefe wrote:
GemStone Smalltalk also supports the {} syntax. One of Smalltalk's strengths is readability. I have many a time had to write:
-- (OrderedCollection new add: something; add: something else; ... add: yet another thing; yourself) asArray. The low-level clutter of this hides the things the collection is composed of. (By the way, I started hacking the compiler to add this, but didn't get too far.) [And, if you are going to modify the compiler, make sure the literals in an Atom get reflected in the compiled method's literal pool. The last time I checked, they weren't.] Thanks, Richard You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/groups/opt_out. |
In reply to this post by John O'Keefe-3
Hi,
I find this particular construct useful in various cases for improving readability:
In this cases usually I do something similar to Richard suggestion, but it's too much verbose. Gabriel
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/groups/opt_out. |
Hi Guys,
As I said, I like this little bit of syntactic sugar but when asked by John, I couldn't come up with good examples. I think it can often help readability, not just by putting what you want in an array with less messages but by not breaking up the code above and below it. Thanks for the examples and the support. Hopefully it won't take much to add it if Instantiations chooses to take a look at doing so. You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/groups/opt_out. |
In reply to this post by gcotelli
Gabriel, good points, especially the tests and bidWithArguments. On the other hand, I don't really like the construct, because I find it hard to read. You need to remember what Collection class is constructed with {}, and that is not very consistent with the rest of Smalltalk. At least IMO. Joachim
-- Am Freitag, 12. Juli 2013 14:55:17 UTC+2 schrieb Gabriel Cotelli: Hi, You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/groups/opt_out. |
There's one more scenario, ich which I sometimes wish for a quick, hacky way to produce some collection: when I write a snippet of coe in a workspace that's just a quick hack to test something.
Not really a string argument in advance of the {} syntax...
-- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/groups/opt_out. |
In reply to this post by John O'Keefe-3
Hi John,
I just ran into a case where this would be useful. I would like to create a large (100+ elements) array of points. I would like to treat/create the points as constants in the array like: {4@5. 7@6. 8@9....} Lou
-- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/groups/opt_out. |
Allthough not relevent for VAST, Pharo Morphic uses this for building its interfaces easily, eg: toolbar ^ toolbar ifNil: [ | tools | tools := self newToolbar: { self newButtonFor: self getState: nil action: #save arguments: nil getEnabled: nil labelForm: (ArchiImages save scaledToSize: 16@16) help: 'Save'. self newToolSpacer. self newButtonFor: self getState: nil action: #saveAs arguments: nil getEnabled: nil labelForm: (ArchiImages saveas scaledToSize: 16@16) help: 'Save As'. self newToolSpacer.....}. toolbar := self newToolDockingBar addMorph: tools] On Thu, Aug 1, 2013 at 9:50 PM, Louis LaBrunda <[hidden email]> wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/groups/opt_out. |
Hi all,
Just for the record. I also find it very useful, and would love to have it in VA Smalltalk as well. Cheers, Bernhard Am 02.08.2013 um 10:42 schrieb Dusty: > Allthough not relevent for VAST, Pharo Morphic uses this for building its interfaces easily, eg: > > toolbar > ^ toolbar ifNil: [ | tools | > tools := self newToolbar: { > self newButtonFor: self getState: nil action: #save arguments: nil getEnabled: nil > labelForm: (ArchiImages save scaledToSize: 16@16) help: 'Save'. > self newToolSpacer. > self newButtonFor: self getState: nil action: #saveAs arguments: nil getEnabled: nil > labelForm: (ArchiImages saveas scaledToSize: 16@16) help: 'Save As'. > self newToolSpacer.....}. > > toolbar := self newToolDockingBar addMorph: tools] > > > On Thu, Aug 1, 2013 at 9:50 PM, Louis LaBrunda <[hidden email]> wrote: > Hi John, > > On Thursday, July 11, 2013 10:54:05 AM UTC-4, John O'Keefe wrote: > Lou - > > snip.. > > Can you give some examples of "...times when I think this would be very useful"? > > snip.. > > I just ran into a case where this would be useful. I would like to create a large (100+ elements) array of points. I would like to treat/create the points as constants in the array like: {4@5. 7@6. 8@9....} > > Lou > > -- > You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. > To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. > To post to this group, send email to [hidden email]. > Visit this group at http://groups.google.com/group/va-smalltalk. > For more options, visit https://groups.google.com/groups/opt_out. > > > > > -- > You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. > To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. > To post to this group, send email to [hidden email]. > Visit this group at http://groups.google.com/group/va-smalltalk. > For more options, visit https://groups.google.com/groups/opt_out. > > -- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/groups/opt_out. |
Free forum by Nabble | Edit this page |