Re: [Pharo-dev] String Interpolation

2017-10-04 Thread Esteban A. Maringolo
2017-10-04 16:49 GMT-03:00 Denis Kudriashov : > 2017-10-04 21:38 GMT+02:00 Esteban A. Maringolo : >>> It is not compiled time but behaviour is very close to it. >>> The trick is that first time execution will replace full expression with >>> the result

Re: [Pharo-dev] String Interpolation

2017-10-04 Thread Denis Kudriashov
2017-10-04 21:38 GMT+02:00 Esteban A. Maringolo : > 2017-10-04 6:46 GMT-03:00 Denis Kudriashov : > >> Hi Igor. >> >> Did you see that we have now #asMethodConstant? >> >> DateAndTime now asMethodConst >> >> >> It is not compiled time but behaviour is

Re: [Pharo-dev] String Interpolation

2017-10-04 Thread Esteban A. Maringolo
2017-10-04 6:46 GMT-03:00 Denis Kudriashov : > Hi Igor. > > Did you see that we have now #asMethodConstant? > > DateAndTime now asMethodConst > > > It is not compiled time but behaviour is very close to it. > The trick is that first time execution will replace full

Re: [Pharo-dev] String Interpolation

2017-10-04 Thread Igor Stasenko
On 4 October 2017 at 22:30, Igor Stasenko wrote: > > > On 4 October 2017 at 17:27, Sean P. DeNigris > wrote: > >> Igor Stasenko wrote >> > IMO, best would be to make it via compiler plugin. >> >> It seems there is always a tension between

Re: [Pharo-dev] String Interpolation

2017-10-04 Thread Igor Stasenko
On 4 October 2017 at 12:46, Denis Kudriashov wrote: > Hi Igor. > > Did you see that we have now #asMethodConstant? > > DateAndTime now asMethodConst > > > It is not compiled time but behaviour is very close to it. > The trick is that first time execution will replace full

Re: [Pharo-dev] String Interpolation

2017-10-04 Thread Igor Stasenko
On 4 October 2017 at 17:27, Sean P. DeNigris wrote: > Igor Stasenko wrote > > IMO, best would be to make it via compiler plugin. > > It seems there is always a tension between newbie-friendliness/purity and > max-performance/deployment. There are so many other things about

Re: [Pharo-dev] String Interpolation

2017-10-04 Thread Sean P. DeNigris
Igor Stasenko wrote > IMO, best would be to make it via compiler plugin. It seems there is always a tension between newbie-friendliness/purity and max-performance/deployment. There are so many other things about a Smalltalk image that are insecure and any compiler "tricks" are additional places

Re: [Pharo-dev] String Interpolation

2017-10-04 Thread Denis Kudriashov
Hi Igor. Did you see that we have now #asMethodConstant? DateAndTime now asMethodConst It is not compiled time but behaviour is very close to it. The trick is that first time execution will replace full expression with the result as literal (the receiver of #asMethodConst). So at second time

Re: [Pharo-dev] String Interpolation

2017-10-04 Thread Sven Van Caekenberghe
> On 4 Oct 2017, at 11:36, Igor Stasenko wrote: > > IMO, best would be to make it via compiler plugin. > > Same, as i proposed for object literals, > a compiler could detect a pattern interpolate Which means the #interpolate message send is compiled away, right ? So no

Re: [Pharo-dev] String Interpolation

2017-10-04 Thread Igor Stasenko
IMO, best would be to make it via compiler plugin. Same, as i proposed for object literals, a compiler could detect a pattern interpolate and replace it at compile time to produce/expand it into proper context-aware semantic, something like this: {'a' . x . 'b' . y. 'c' .z } gather: #asString

Re: [Pharo-dev] String Interpolation

2017-10-04 Thread Thierry Goubier
2017-10-04 9:50 GMT+02:00 Guillermo Polito : > if the compiler plugin correctly models such special syntax with special > AST nodes, that could be even possible without much effort > Interesting. Would that imply that by having those special ast nodes, we would get the

Re: [Pharo-dev] String Interpolation

2017-10-04 Thread Guillermo Polito
if the compiler plugin correctly models such special syntax with special AST nodes, that could be even possible without much effort On Tue, Oct 3, 2017 at 5:42 PM, Denis Kudriashov wrote: > > 2017-10-03 17:39 GMT+02:00 Denis Kudriashov : > >> Hi. >>

Re: [Pharo-dev] String Interpolation

2017-10-03 Thread Henrik Sperre Johansen
Sven Van Caekenberghe-2 wrote > Nicolas, > >> On 28 Sep 2017, at 23:56, Nicolas Cellier > nicolas.cellier.aka.nice@ > wrote: >> >> Hi Sven, >> for now it works because the context into which the block is executed >> still has full access to the variables and receiver of outer context from >>

Re: [Pharo-dev] String Interpolation

2017-10-03 Thread Denis Kudriashov
2017-10-03 17:39 GMT+02:00 Denis Kudriashov : > Hi. > > While idea looks cool it will require a lot of tool support. Senders, > var/class references, rename refactorings should be aware of it > And I forgot debugger. It should be possible to step over "interpolated

Re: [Pharo-dev] String Interpolation

2017-10-03 Thread Denis Kudriashov
2017-10-03 17:39 GMT+02:00 Denis Kudriashov : > Hi. > > While idea looks cool it will require a lot of tool support. Senders, > var/class references, rename refactorings should be aware of it > Language designers do not care about it of course :) > > 2017-10-03 17:29

Re: [Pharo-dev] String Interpolation

2017-10-03 Thread Denis Kudriashov
Hi. While idea looks cool it will require a lot of tool support. Senders, var/class references, rename refactorings should be aware of it 2017-10-03 17:29 GMT+02:00 Damien Pollet : > On 3 October 2017 at 14:07, Guillermo Polito > wrote: > >>

Re: [Pharo-dev] String Interpolation

2017-10-03 Thread Damien Pollet
On 3 October 2017 at 14:07, Guillermo Polito wrote: > Why not having an opal plugin? > > The opal plugin may read strings in the form: > > "lalala {some expression} lololo" > > and replace at compile time that by: > > "lalala {1} lololo" format { some expression } >

Re: [Pharo-dev] String Interpolation

2017-10-03 Thread Sven Van Caekenberghe
Nicolas, > On 28 Sep 2017, at 23:56, Nicolas Cellier > wrote: > > Hi Sven, > for now it works because the context into which the block is executed still > has full access to the variables and receiver of outer context from which the > block is declared. >

Re: [Pharo-dev] String Interpolation

2017-10-03 Thread Guillermo Polito
Why not having an opal plugin? The opal plugin may read strings in the form: "lalala {some expression} lololo" and replace at compile time that by: "lalala {1} lololo" format { some expression } The thing to think about is what is the delimiter for {some expression}. - a too used one may

Re: [Pharo-dev] String Interpolation

2017-09-29 Thread Sven Van Caekenberghe
> On 29 Sep 2017, at 08:54, Pavel Krivanek wrote: > > This solution will not work for environments without sources too where names > like t1, t2 are used for temporary variables. That is true. I often wonder why we can't keep at least the variables names, it would

Re: [Pharo-dev] String Interpolation

2017-09-29 Thread Sven Van Caekenberghe
> On 29 Sep 2017, at 06:40, Hernán Morales Durand > wrote: > > Hi Sven, > > Is this one the similar to the #evaluate in > http://www.squeaksource.com/evaluablestrings ? Haha, yes that is exactly the same trick. Lukas & Philippe back in 2005, duh. > Cheers, > >

Re: [Pharo-dev] String Interpolation

2017-09-29 Thread Pavel Krivanek
This solution will not work for environments without sources too where names like t1, t2 are used for temporary variables. Anyway, nice idea. -- Pavel Dne čtvrtek 28. září 2017 Sven Van Caekenberghe napsal(a): > Hi, > > I got into a little office discussion about string

Re: [Pharo-dev] String Interpolation

2017-09-28 Thread Hernán Morales Durand
Hi Sven, Is this one the similar to the #evaluate in http://www.squeaksource.com/evaluablestrings ? Cheers, Hernán 2017-09-28 11:20 GMT-03:00 Sven Van Caekenberghe : > Hi, > > I got into a little office discussion about string interpolation as it is > done in different

Re: [Pharo-dev] String Interpolation

2017-09-28 Thread Nicolas Cellier
Hi Sven, for now it works because the context into which the block is executed still has full access to the variables and receiver of outer context from which the block is declared. But it's not necessarily the case in all dialects. In VW for example, I get nil instead of foobar #('loop on value

Re: [Pharo-dev] String Interpolation

2017-09-28 Thread Sven Van Caekenberghe
> On 28 Sep 2017, at 18:50, Nicolas Cellier > wrote: > > > > 2017-09-28 16:20 GMT+02:00 Sven Van Caekenberghe : > Hi, > > I got into a little office discussion about string interpolation as it is > done in different programming languages.

Re: [Pharo-dev] String Interpolation

2017-09-28 Thread Nicolas Cellier
2017-09-28 16:20 GMT+02:00 Sven Van Caekenberghe : > Hi, > > I got into a little office discussion about string interpolation as it is > done in different programming languages. > > In Pharo we have String>>#format: which is pretty nice. It works as > follows: > > | x y | > x :=

Re: [Pharo-dev] String Interpolation

2017-09-28 Thread Sven Van Caekenberghe
> On 28 Sep 2017, at 18:08, Ron Teitelbaum wrote: > > Sorry, I tried to have them included at one point on squeak but I was talked > down. > > I use them a lot! They work with other things besides strings. In Pharo we have #join: and #split: $| join: #('Foo' 'Bar').

Re: [Pharo-dev] String Interpolation

2017-09-28 Thread Ron Teitelbaum
Sorry, I tried to have them included at one point on squeak but I was talked down. I use them a lot! They work with other things besides strings. Collection >> explode: aDelimiter "explode the collection into a collection of collections broken by aDelimiter" "(#(#(1 2) #(3 4)) mergeDelimited:

Re: [Pharo-dev] String Interpolation

2017-09-28 Thread p...@highoctane.be
>From a book about PHP security, there was a chapter about "tainted variables". The concept is that once a variable is written to from a user, all other variables that come into contact with it should be considered tainted from a security perspective. The chapter went about how such variables

Re: [Pharo-dev] String Interpolation

2017-09-28 Thread Sven Van Caekenberghe
> On 28 Sep 2017, at 17:13, Thierry Goubier wrote: > > > > 2017-09-28 17:08 GMT+02:00 Sven Van Caekenberghe : > > > > On 28 Sep 2017, at 16:58, p...@highoctane.be wrote: > > > > I stand corrected. > > > > Nuclear style feature then. > > > > 'Let me

Re: [Pharo-dev] String Interpolation

2017-09-28 Thread Thierry Goubier
2017-09-28 17:08 GMT+02:00 Sven Van Caekenberghe : > > > > On 28 Sep 2017, at 16:58, p...@highoctane.be wrote: > > > > I stand corrected. > > > > Nuclear style feature then. > > > > 'Let me get out of here {Smalltalk snapshot:false andQuit: true}. BOOM' > interpolate > > > > Feels

Re: [Pharo-dev] String Interpolation

2017-09-28 Thread Sven Van Caekenberghe
> On 28 Sep 2017, at 16:55, Ron Teitelbaum wrote: > > Hi All, > > To solve this problem I do this: > > replaceTokensIn: aString > ^self tokens inject: aString into: [:str :assoc | > ((str explode: assoc key) mergeDelimited: assoc value value)]. > >

Re: [Pharo-dev] String Interpolation

2017-09-28 Thread Sven Van Caekenberghe
> On 28 Sep 2017, at 16:58, p...@highoctane.be wrote: > > I stand corrected. > > Nuclear style feature then. > > 'Let me get out of here {Smalltalk snapshot:false andQuit: true}. BOOM' > interpolate > > Feels like > > STR='sudo reboot'; $(STR) > > in bash when one is sudoer. Yeah, but it

Re: [Pharo-dev] String Interpolation

2017-09-28 Thread p...@highoctane.be
I stand corrected. Nuclear style feature then. 'Let me get out of here {Smalltalk snapshot:false andQuit: true}. BOOM' interpolate Feels like STR='sudo reboot'; $(STR) in bash when one is sudoer. Phil On Thu, Sep 28, 2017 at 4:43 PM, Sven Van Caekenberghe wrote: > > > > On

Re: [Pharo-dev] String Interpolation

2017-09-28 Thread Ron Teitelbaum
Hi All, To solve this problem I do this: replaceTokensIn: aString ^self tokens inject: aString into: [:str :assoc | ((str explode: assoc key) mergeDelimited: assoc value value)]. tokens is a collection of key value pairs. aString := 'Dear {!user}'. self tokens: {'{!user}' -> [self user]}.

Re: [Pharo-dev] String Interpolation

2017-09-28 Thread Sven Van Caekenberghe
Thierry, > On 28 Sep 2017, at 16:38, Thierry Goubier wrote: > > Hi Sven, > > Jason and Andrew wrote a string interpolation implementation for Andrew's > language, Grace, in the parser. It works rather well and isn't too difficult > to implement... Like I said, I

Re: [Pharo-dev] String Interpolation

2017-09-28 Thread Sven Van Caekenberghe
> On 28 Sep 2017, at 16:27, p...@highoctane.be wrote: > > We also have > http://norbert.hartl.name/blog/2013/10/03/mustache-templates-for-smalltalk/ > > Phil Yes, Mustache is a cool templating engine, but it is similar to #format: not to #interpolate. With true string interpolation, you do

Re: [Pharo-dev] String Interpolation

2017-09-28 Thread Thierry Goubier
Hi Sven, Jason and Andrew wrote a string interpolation implementation for Andrew's language, Grace, in the parser. It works rather well and isn't too difficult to implement... The equivalent would be to add it to RB Parser, and, security wise, it would be as vulnerable as calling Compiler

Re: [Pharo-dev] String Interpolation

2017-09-28 Thread p...@highoctane.be
We also have http://norbert.hartl.name/blog/2013/10/03/mustache-templates-for-smalltalk/ Phil On Thu, Sep 28, 2017 at 4:20 PM, Sven Van Caekenberghe wrote: > Hi, > > I got into a little office discussion about string interpolation as it is > done in different programming