Hi,
Occasionally I find reference to ##(self) and ##(icon) etc, and I've tried to find what it is. In a workspace #(self) returns an array, and ##(self) return an UndefinedObject, but I don't quite get it. Would I be right in assuming ## is a special method? Is there any ware in Help a details explanation of special operators and symbols. eg / // # ## ^ etc (I know some but not all of the uses)? Thanks Theo |
Theo,
> Occasionally I find reference to ##(self) and ##(icon) etc, and I've > tried to find what it is. > In a workspace #(self) returns an array, and ##(self) return an > UndefinedObject, but I don't quite get it. Would I be right in > assuming ## is a special method? > > Is there any ware in Help a details explanation of special operators > and symbols. eg / // # ## ^ etc (I know some but not all of the uses)? A quick Google reveals this thread (amonst others) that explains the ##() syntax: http://groups.google.com/group/comp.lang.smalltalk/browse_frm/thread/b56 30d99756c232b/2482c82d815c9dba?lnk=st&q=dolphin+smalltalk+%23%23+constan t&rnum=1#2482c82d815c9dba Best regards, -- Andy Bower Dolphin Support www.object-arts.com |
In reply to this post by Theo Pronk
> Is there any ware in Help a details explanation of special operators
> and symbols. eg / // # ## ^ etc (I know some but not all of the uses)? #(self) creates a literal array with the literal symbol #self as the single element. However, ##(self) is sort of like, a compile time inline. Basically the message/object gets evaluated at compile time rather than runtime. so you can do something like: | secondsInAWeek | secondsInAWeek := ##(60 * 60 * 24 * 7). And instead of being evaluated every time the message it is contained within is invoked, it is evaluated once, at compile time, so the actual bytecode that is generated, is the same as if you had used a magic number constant like so: | secondsInAWeek | secondsInAWeek := 604800. ##() doesn't work in a workspace, only in compiled methods. |
In reply to this post by Andy Bower-3
Andy Bower wrote:
> A quick Google reveals this thread (amonst others) that explains the > ##() syntax: Can you suggest search terms for Google /without/ knowing what the ##(...) construct means in advance ? -- chris |
In reply to this post by Sean M-4
Sean,
> ##() doesn't work in a workspace, only in compiled methods. Small correction -- ##( ... ) does work in workspaces. The only difference is that "self" is bound to nil in a workspace so ##( self ) will evaluate to nil there. In a method ##( self ) will evaluate to the class where the method is defined -- there's no profundly logical reason why that should be the case, but it's handy that /at compile time/ self evaluates to the class. -- chris |
> Small correction -- ##( ... ) does work in workspaces. The only
> difference is > that "self" is bound to nil in a workspace so ##( self ) will evaluate to > nil > there. Hey Chris, Whoops! I think I tried to evaluate some ##() code once in a workspace in Dolphin 5 and it didn't work. I can't remember the exact reason, but it left me with the impression that it didn't work in a workspace, hence my eagerness to perpetuate that myth. Thanks for pointing that out. Regards, Sean |
In reply to this post by Chris Uppal-3
Chris,
> > A quick Google reveals this thread (amonst others) that explains the > > ##() syntax: > > Can you suggest search terms for Google without knowing what the > ##(...) construct means in advance ? Well I used "dolphin smalltalk ## syntax" as a search term for Google Groups. It's the second item in the list. Best regards -- Andy Bower Dolphin Support www.object-arts.com |
Andy,
> > Can you suggest search terms for Google without knowing what the > > ##(...) construct means in advance ? > > Well I used "dolphin smalltalk ## syntax" as a search term for Google > Groups. It's the second item in the list. Only a coincidence, I'm afraid, Google ignores the ## bit. If you repeat the test without the ## you get exactly the same results... -- chris |
In reply to this post by Theo Pronk
Theo,
If you're new to ST and DST like me, you'll find Bill Schwab's DSDN application and Ian Bartholomew's newsgroup archive (which you unzip to the DSDN\Archive directory) invaluable. (Also grab Ian's Chunk Browser if you haven't http://www.smalltalk.vispa.com/idbchunkbrowser.html) You can get DSDN here: http://needle.anest.ufl.edu/anest4/bills/DSDN_news.htm And the newsgroup archives here: http://www.smalltalk.vispa.com/newsarchive.html These tools are the only reason I haven't been hounding these people daily ;) |
In reply to this post by Theo Pronk
Theo,
> Is there any ware in Help a details explanation of special operators > and symbols. eg / // # ## ^ etc (I know some but not all of the uses)? It's a bit difficult to judge what is or isn't well known and understood in Dolphin, but here's a couple that might not be common knowledge ... #[1 2 3 4 5] as #(1 2 3 4 5) but answers a ByteArray - so the contents must be Integers between 0 and 255 1 -> 2 Answers an Association with a key (of 1) and a value (of 2) -- Ian Use the Reply-To address to contact me (limited validity). Mail sent to the From address is ignored. |
In reply to this post by Chris Uppal-3
"Chris Uppal" <[hidden email]> wrote in message
news:43aaaa22$0$260$[hidden email]... > Andy, > >> > Can you suggest search terms for Google without knowing what the >> > ##(...) construct means in advance ? >> >> Well I used "dolphin smalltalk ## syntax" as a search term for Google >> Groups. It's the second item in the list. > > Only a coincidence, I'm afraid, Google ignores the ## bit. If you repeat > the > test without the ## you get exactly the same results... > > -- chris OT but tangential: I can remember years ago I had a heck of a time searching Google for "DVD+R" information. There was no way I could limit the search to only pages that actually mentioned DVD+R. I actually wrote to Google to explain the issue, and they replied that it was a limitation to their index. Ever since product names that include novel non-alphanumeric characters always annoy me. ;) It looks like the "DVD+R" issue still exists. I think they should consider an index enhancement to accommodate at least the more common of these special cases. "##(" might not be common enough, but certainly "DVD+R" would be. Chris |
In reply to this post by Sean M-4
> Sean
> However, ##(self) is sort of like, a compile time inline. Basically the > message/object gets evaluated at compile time rather than runtime. So ##(... is like a compiler directive? Theo |
In reply to this post by John Rubier
John,
I've been playing with Smalltalk for years, but only get to work with it as a hobby. My income comes from AS/400 and RPG quite different. So I never quite get to remember all of the little special thing and often have to rediscovering them. Thanks Theo |
In reply to this post by Andy Bower-3
Andy,
This is a wish list: can you add a section to help with special operators and/or compiler directives? eg in Excel help when you select "operators" you get a nice little overview on + - / etc Possibly under appendix A called "Operators" or "Compiler directives" etc showing + / - // ##() #() #[] ##[] -> etc with a short explanation and some examples Thanks, Theo |
In reply to this post by Christopher J. Demers
Christopher J. Demers wrote:
> I think they should consider an index enhancement to accommodate > at least the more common of these special cases. "##(" might not be > common enough, but certainly "DVD+R" would be. Some of the other search engines do index each character. I believe that anything based on the FAST engine does, but I don't know which search portals use it. Unfortunately only Google indexes Usenet -- on the rare occasions where hasn't trashed its records. Fortunately there's Ian's archive, and a quick check of that reveals 159 hits for ##( between 1997-04-01 and 2005-10-28. Thanks Ian ! -- chris |
Free forum by Nabble | Edit this page |