Re: [Pharo-users] Literals (Richard Sargent)

2018-04-29 Thread Debiller 777
Well, set idea was just a small proposal, which had to help me in solving a harder problem. I wanted to add something like extensionable literal. The idea is that when compiler sees some special literal, it reads it, turns into an object and sends #parse message to it. After that literal answers so

Re: [Pharo-users] Literals

2018-04-28 Thread Sean P. DeNigris
Denis Kudriashov wrote > We have similar mechanizm in Pharo. Look at > http://dionisiydk.blogspot.fr/2016/07/magic-with-pharo-reflectivity.html Wow! That's really cool. I like that we can do it without adding *any* syntax. Tiny syntax is one of the more special things about the Smalltalk language.

Re: [Pharo-users] Literals

2018-04-28 Thread Richard Sargent
Debiller 777 wrote > You know, literals are quite useful in case when you want to shorten some > object initialization. For example #() and {} for arrays and $[]for byte > arrays. However, if there is a way to add custom literals, for example for > sets (something like #{} I guess)? how to do it? a

Re: [Pharo-users] Literals

2018-04-28 Thread Denis Kudriashov
Hi. сб, 28 апр. 2018 г., 1:26 Richard Sargent < richard.sarg...@gemtalksystems.com>: > On Fri, Apr 27, 2018 at 3:58 PM, Esteban A. Maringolo < > emaring...@gmail.com> wrote: > >> oh, you were talking about how te VM views the object, >> I was thinking in terms of how the compiler sees the text. >>

Re: [Pharo-users] Literals (Richard O'Keefe)

2018-04-28 Thread Debiller 777
Can you please tell more about ##() thing?

Re: [Pharo-users] Literals

2018-04-28 Thread Richard O'Keefe
A On 28 April 2018 at 20:21, Peter Uhnák wrote: > What would entail actually extending the syntax and adding the set literal? > > From my brief observations (when I was discussing this with OP on discord): > > * adding a new AST node > * extend RBParser > * extend IRMethod/IRTranslator... maybe

Re: [Pharo-users] Literals

2018-04-28 Thread Peter Uhnák
What would entail actually extending the syntax and adding the set literal? >From my brief observations (when I was discussing this with OP on discord): * adding a new AST node * extend RBParser * extend IRMethod/IRTranslator... maybe generating bytecode for `{ ... } asSet` instead would be enoug

Re: [Pharo-users] Literals

2018-04-27 Thread Richard O'Keefe
The ## syntax that some Smalltalks have (Smalltalk/X, for example, which calls it a Dolphin extension) is related to Common Lisp's #.e the result of evaluating e at *read* time, taken as a literal #,e the result of evaluating e at *load* time, taken as a lite

Re: [Pharo-users] Literals

2018-04-27 Thread lb
Hi, I think the question is How automaticly create literal's objects , not initialize. e.g 'aString' #aSymbol { anArray} #[] Cheers Liang

Re: [Pharo-users] Literals

2018-04-27 Thread Ben Coman
On 28 April 2018 at 03:34, Clément Bera wrote: > The guy who asked the question said: "...when you want to shorten some > object initialization" > > Using ClassVariable is an alternative way to shorten object > initialization, reading a ClassVariable is almost the same performance as > reading a

Re: [Pharo-users] Literals

2018-04-27 Thread Richard Sargent
On Fri, Apr 27, 2018 at 3:58 PM, Esteban A. Maringolo wrote: > oh, you were talking about how te VM views the object, > I was thinking in terms of how the compiler sees the text. > > So I'm talking about literals "syntax". > > Thanks anyway for the "trick" :) > Another common technique is a "onc

Re: [Pharo-users] Literals

2018-04-27 Thread Esteban A. Maringolo
oh, you were talking about how te VM views the object, I was thinking in terms of how the compiler sees the text. So I'm talking about literals "syntax". Thanks anyway for the "trick" :) On 27/04/2018 16:34, Clément Bera wrote: > The guy who asked the question said: "...when you want to shorten

Re: [Pharo-users] Literals

2018-04-27 Thread Clément Bera
The guy who asked the question said: "...when you want to shorten some object initialization" Using ClassVariable is an alternative way to shorten object initialization, reading a ClassVariable is almost the same performance as reading a literal, so that looked like a good alternative to me. Both

Re: [Pharo-users] Literals

2018-04-27 Thread Esteban A. Maringolo
On 27/04/2018 15:35, Richard Sargent wrote: > On Fri, Apr 27, 2018 at 2:08 PM, Esteban A. Maringolo > mailto:emaring...@gmail.com>> wrote: > As far as I knew the only way to have new literals was to modify the > compiler. > > > Yes. > > VA Smalltalk has an interesting syntax extension w

Re: [Pharo-users] Literals

2018-04-27 Thread Richard Sargent
On Fri, Apr 27, 2018 at 2:08 PM, Esteban A. Maringolo wrote: > Hi Clément, > > On 27/04/2018 10:32, Clément Bera wrote: > > Obviously sets are not as easy to deal with. You cannot mutate empty > > arrays/bytearrays, if you concatenate something it creates a new object. > > You can add things in s

Re: [Pharo-users] Literals

2018-04-27 Thread Esteban A. Maringolo
Hi Clément, On 27/04/2018 10:32, Clément Bera wrote: > Obviously sets are not as easy to deal with. You cannot mutate empty > arrays/bytearrays, if you concatenate something it creates a new object. > You can add things in sets. So you need to be careful... You can make > the object read-only to a

Re: [Pharo-users] Literals

2018-04-27 Thread Clément Bera
Not really. You can use ClassVariables though. Here's an example for Sets: Object subclass: #MyClass instanceVariableNames: '' classVariableNames: 'MyClassVar' package: 'MyPackage' MyClass class>>initialize super initialize. MyClassVar := Set new. MyClass>>foo self bar: MyClassVar