Pharo-dev
By thread
pharo-dev@lists.pharo.org
By month
Messages by month
- ----- 2026 -----
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
September 2017
- 546 messages
Re: [Pharo-dev] Epicea wishlist
by Stephane Ducasse
Tx Martin.
On Thu, Sep 28, 2017 at 4:33 PM, Martin Dias <tinchodias(a)gmail.com> wrote:
> Stef, ok I add your request in the issue tracker:
>
> https://pharo.fogbugz.com/f/cases/20474/Epicea-Keep-filter-across-session-i…
>
> It's kind of funny because the filters were kept across seassions and I
> *intentionally* added the filter cleaning when session selection changes.
> IMO it was misleading to keep them as you want, but also I understand your
> point... I think moving the filters widget to other place in the window can
> do it.
>
> MartÃn
>
> On Thu, Sep 7, 2017 at 3:15 AM, Stephane Ducasse <stepharo.self(a)gmail.com>
> wrote:
>>
>> Hi martin
>>
>> I'm missing two features:
>>
>> - keep the filter across session because this is boring to have to
>> redo them all over.
>> - a search for entities accross session.
>> - a search inside a session
>> For example I was looking for all the changes I did to the UI part of
>> my application but I was doing many development
>> loading different unrelated package and saving after.
>>
>> Right now you can restrict to view changes but only if you have a
>> first entity of the package for example so you have to look first is
>> there an entity of this package.
>>
>> Stef
>>
>
Sept. 28, 2017
Re: [Pharo-dev] Call for little tasks for GCI
by phil@highoctane.be
What about
LD_LIBRARY_PATH=<sqlite3place>;$LD_LIBRARYPATH ./pharo-ui some.image
Phil
On Thu, Sep 28, 2017 at 7:41 PM, Jigyasa Grover <grover.jigyasa1(a)gmail.com>
wrote:
> Hello hernanmd,
>
> Please check out the link to the repository
> (github.com/jigyasa-grover/GCI-2017-with-Pharo) it should work for you, I
> added you as a collaborator.
>
> For more details on the contest and type of tasks to be created, please
> refer:
> 1. Resources in the repository
> 2. Invitation Letter
> (http://forum.world.st/Let-s-prepare-for-Google-Code-In-
> 2017-with-Pharo-Consortium-td4966890.html)
>
> Looking forward to significant contributions from your side !
>
> Best Regrads
> Jigyasa Grover
>
>
>
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Developers-f1294837.html
>
>
Sept. 28, 2017
Re: [Pharo-dev] Call for little tasks for GCI
by Jigyasa Grover
Hello hernanmd,
Please check out the link to the repository
(github.com/jigyasa-grover/GCI-2017-with-Pharo) it should work for you, I
added you as a collaborator.
For more details on the contest and type of tasks to be created, please
refer:
1. Resources in the repository
2. Invitation Letter
(http://forum.world.st/Let-s-prepare-for-Google-Code-In-2017-with-Pharo-Cons…)
Looking forward to significant contributions from your side !
Best Regrads
Jigyasa Grover
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Developers-f1294837.html
Sept. 28, 2017
Re: [Pharo-dev] String Interpolation
by Sven Van Caekenberghe
> On 28 Sep 2017, at 18:50, Nicolas Cellier <nicolas.cellier.aka.nice(a)gmail.com> wrote:
>
>
>
> 2017-09-28 16:20 GMT+02:00 Sven Van Caekenberghe <sven(a)stfx.eu>:
> 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 := 123.
> y := #foo.
> 'x={1} and y={2}' format: { x. y }.
>
> It is also possible to use a dictionary with keys, like this:
>
> | x y |
> x := 123.
> y := #foo.
> 'x={x} and y={y}' format: { #x->x. #y->y } asDictionary.
>
> But this is not true string interpolation as described in [ https://en.wikipedia.org/wiki/String_interpolation ]. The idea is to write the value generating expressions directly inside the strings.
>
> Since in Pharo we add features not by extending the syntax but by adding messages I wondered if it could be done for string interpolation. The goal is to make the following work:
>
> | x y |
> x := 123.
> y := #foo.
> 'It seems x equals {x} and y equals {y} while Pi is still {Float pi}' interpolate.
>
> => 'It seems x equals 123 and y equals foo while Pi is still 3.141592653589793'
>
> Here is the implementation I came up with:
>
> String>>#interpolate
> "Format the receiver by interpolating the evaluation of expressions
> in between curly brackets in the context of the sender as in the following 3 oneline examples.
> 'Today is {Date today}' interpolate.
> | x | x := 123. 'x equals {x} and pi equals {Float pi}' interpolate.
> 'In {#strings} you can escape \{ by prefixing it with \\' interpolate."
>
> | senderContext |
> senderContext := thisContext sender.
> ^ self class new: self size streamContents: [ :out | | stream |
> stream := self readStream.
> [ stream atEnd ] whileFalse: [ | currentChar |
> (currentChar := stream next) == ${
> ifTrue: [ | expression result |
> expression := stream upTo: $}.
> result := Compiler new
> evaluate: expression in: senderContext to: nil notifying: nil ifFail: [ ^ nil ] logged: false.
> out nextPutAll: result asString ]
> ifFalse: [
> currentChar == $\
> ifTrue: [ stream atEnd ifFalse: [ out nextPut: stream next ] ]
> ifFalse: [ out nextPut: currentChar ] ] ] ]
>
> It is a hack that could certainly be improved. And there is of course an obvious security problem.
>
> Thoughts ?
>
> Sven
>
>
> Nice!
> The only objection I see is that it may fail in blocks if they don't know that they have to refer to outer context, especially once we have clean blocks
Yes, there are probably some edge cases. Error handling is tricky too.
> | outer |
> outer := 'foobar'.
> ^#( 1 2 3 ) collect: [:x | 'loop on value {x} in {outer}' interpolate]
That example works for me in a Playground. How does it fail for you ?
Sept. 28, 2017
Re: [Pharo-dev] String Interpolation
by Nicolas Cellier
2017-09-28 16:20 GMT+02:00 Sven Van Caekenberghe <sven(a)stfx.eu>:
> 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 := 123.
> y := #foo.
> 'x={1} and y={2}' format: { x. y }.
>
> It is also possible to use a dictionary with keys, like this:
>
> | x y |
> x := 123.
> y := #foo.
> 'x={x} and y={y}' format: { #x->x. #y->y } asDictionary.
>
> But this is not true string interpolation as described in [
> https://en.wikipedia.org/wiki/String_interpolation ]. The idea is to
> write the value generating expressions directly inside the strings.
>
> Since in Pharo we add features not by extending the syntax but by adding
> messages I wondered if it could be done for string interpolation. The goal
> is to make the following work:
>
> | x y |
> x := 123.
> y := #foo.
> 'It seems x equals {x} and y equals {y} while Pi is still {Float pi}'
> interpolate.
>
> => 'It seems x equals 123 and y equals foo while Pi is still
> 3.141592653589793'
>
> Here is the implementation I came up with:
>
> String>>#interpolate
> "Format the receiver by interpolating the evaluation of expressions
> in between curly brackets in the context of the sender as in the
> following 3 oneline examples.
> 'Today is {Date today}' interpolate.
> | x | x := 123. 'x equals {x} and pi equals {Float pi}' interpolate.
> 'In {#strings} you can escape \{ by prefixing it with \\' interpolate."
>
> | senderContext |
> senderContext := thisContext sender.
> ^ self class new: self size streamContents: [ :out | | stream |
> stream := self readStream.
> [ stream atEnd ] whileFalse: [ | currentChar |
> (currentChar := stream next) == ${
> ifTrue: [ | expression result |
> expression := stream upTo: $}.
> result := Compiler new
> evaluate: expression in: senderContext to: nil notifying:
> nil ifFail: [ ^ nil ] logged: false.
> out nextPutAll: result asString ]
> ifFalse: [
> currentChar == $\
> ifTrue: [ stream atEnd ifFalse: [ out nextPut: stream next ]
> ]
> ifFalse: [ out nextPut: currentChar ] ] ] ]
>
> It is a hack that could certainly be improved. And there is of course an
> obvious security problem.
>
> Thoughts ?
>
> Sven
>
>
Nice!
The only objection I see is that it may fail in blocks if they don't know
that they have to refer to outer context, especially once we have clean
blocks
| outer |
outer := 'foobar'.
^#( 1 2 3 ) collect: [:x | 'loop on value {x} in {outer}' interpolate]
Sept. 28, 2017
Re: [Pharo-dev] [Ann] Class meta annotations
by Denis Kudriashov
2017-09-28 18:17 GMT+02:00 Denis Kudriashov <dionisiydk(a)gmail.com>:
> 2017-09-25 17:57 GMT+02:00 Denis Kudriashov <dionisiydk(a)gmail.com>:
>
>> 2017-09-25 17:38 GMT+02:00 Stephane Ducasse <stepharo.self(a)gmail.com>:
>>
>>> I agree with guille. We should just called them class annotations.
>>>
>>> Denis what is a declared instance (is it an object returned by the
>>> method having the annotation)
>>> but can we find a better name.
>>>
>>
>> My idea that the method with pragma #classMetaAnnotation is the
>> declaration of annotation. Internally this declaration creates instance of
>> specified annotation which cached by system. And users access all these
>> declared instances for reflection purposes.
>>
>>
> Maybe #registeredInstances would be better?
>
So I rename these messages too. I think it's better.
>
>> Also annotation has inst var declarationSelector.
>>
>
>>
>>> may be effectiveInstances?
>>>
>>
>> I don't like this name. I not understand "effective" in that context.
>>
>>
>>>
>>>
>>> On Mon, Sep 25, 2017 at 5:09 PM, Guillermo Polito <
>>> guillermopolito(a)gmail.com> wrote:
>>>
>>>> Why calling them meta-annotation and not just annotation? Annotations
>>>> are in general already meta :)
>>>>
>>>> On Mon, Sep 25, 2017 at 5:01 PM, Denis Kudriashov <dionisiydk(a)gmail.com
>>>> > wrote:
>>>>
>>>>> Hi.
>>>>>
>>>>> I glad to present one class package which introduces reusable
>>>>> mechanism for first class annotations.
>>>>>
>>>>> The project can be found on github https://github.com/dion
>>>>> isiydk/ClassMetaAnnotation.
>>>>> And I tried to describe why it is needed in my blog
>>>>> http://dionisiydk.blogspot.fr/2017/09/class-meta-annotations.html.
>>>>>
>>>>> And here is overview:
>>>>>
>>>>> Every annotation should be subclass of ClassMetaAnnotation. To attach
>>>>> it to class you create new class side method which will return an instance
>>>>> of the annotation. Method should be marked with pragma #classMetaAnnotation:
>>>>>
>>>>>
>>>>> MyClass class>>specialAnnotation
>>>>>
>>>>> <classMetaAnnotation>
>>>>>
>>>>> ^MySpecialAnnotation new
>>>>>
>>>>>
>>>>> To query annotations from system there are two methods:
>>>>>
>>>>> 1) You can ask concrete annotation class for all declared instances:
>>>>>
>>>>> MySpecialAnnotation declaredInstances
>>>>>
>>>>> 2) You can ask given class for all attached annotations:
>>>>>
>>>>> MyClass metaAnnotations
>>>>>
>>>>> Every annotation includes information about annotated class and the
>>>>> selector of declaring method.
>>>>> All annotations are cached. So it is cheap to query them. There are
>>>>> extra messages to enumerate annotations using block.
>>>>>
>>>>> Now let's discuss it. I think it can be good addition for the Pharo 7.
>>>>> Especially that it is very small code.
>>>>>
>>>>> Also I would like to thank Marcus who helps me realize this concept in
>>>>> Commander and Calypso which I start simplify with this library.
>>>>>
>>>>> Best regards,
>>>>> Denis
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>>
>>>>
>>>> Guille Polito
>>>>
>>>> Research Engineer
>>>>
>>>> Centre de Recherche en Informatique, Signal et Automatique de Lille
>>>>
>>>> CRIStAL - UMR 9189
>>>>
>>>> French National Center for Scientific Research - *http://www.cnrs.fr
>>>> <http://www.cnrs.fr>*
>>>>
>>>>
>>>> *Web:* *http://guillep.github.io* <http://guillep.github.io>
>>>>
>>>> *Phone: *+33 06 52 70 66 13 <+33%206%2052%2070%2066%2013>
>>>>
>>>
>>>
>>
>
Sept. 28, 2017
Re: [Pharo-dev] String Interpolation
by Sven Van Caekenberghe
> On 28 Sep 2017, at 18:08, Ron Teitelbaum <ron(a)usmedrec.com> 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').
=> 'Foo|Bar'
$| split: 'Foo|Bar'.
=> an OrderedCollection('Foo' 'Bar')
Not 100% the same, but quite close. Handy indeed.
> Collection >> explode: aDelimiter
> "explode the collection into a collection of collections broken by aDelimiter"
> "(#(#(1 2) #(3 4)) mergeDelimited: Character tab ) explode: Character tab = an OrderedCollection(#(1 2) #(3 4))
> 'abcdef' explode: 'cd' = an OrderedCollection('ab' 'ef')"
> | resultCollection starting aDelimiterPosition aDelimiterSize |
> self ifEmpty: [^self].
> resultCollection := OrderedCollection new.
> aDelimiterSize := aDelimiter isCollection ifTrue: [aDelimiter size] ifFalse: [1].
> starting := 1.
> [aDelimiterPosition := aDelimiter isCollection ifTrue: [self indexOfSubCollection: aDelimiter startingAt: starting] ifFalse: [self indexOf: aDelimiter startingAt: starting ifAbsent: [0]].
> aDelimiterPosition > 0] whileTrue: [
> resultCollection add: (self copyFrom: starting to: aDelimiterPosition - 1).
> starting := aDelimiterPosition + aDelimiterSize.
> ].
> resultCollection add: (self copyFrom: starting to: self size).
> ^resultCollection
>
> Collection >> mergeDelimited: anObject
> "return to reciever a collection with each element concatenated to remove imbeded collections"
> "#(#(1 2) #(3 4)) mergeDelimited: Character tab = #(1 2 Character tab 3 4), #('ab' 'cd') mergeDelimited: Character cr = 'ab
> cd' "
> | returnCollection aSeperator |
> self ifEmpty: [^self].
> aSeperator := anObject isCollection ifTrue: [anObject] ifFalse: [Array with: anObject].
> returnCollection := self first species new.
> self copy from: 1 to: self size -1 do: [:a |
> a ifNotNil: [
> returnCollection := returnCollection, a, aSeperator
> ].
> ].
> ^returnCollection, self last
>
> On Thu, Sep 28, 2017 at 11:25 AM, Sven Van Caekenberghe <sven(a)stfx.eu> wrote:
>
>
> > On 28 Sep 2017, at 17:13, Thierry Goubier <thierry.goubier(a)gmail.com> wrote:
> >
> >
> >
> > 2017-09-28 17:08 GMT+02:00 Sven Van Caekenberghe <sven(a)stfx.eu>:
> >
> >
> > > On 28 Sep 2017, at 16:58, phil(a)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 is always the original programmer who writes the template (including the 'Smalltalk snapshot:false andQuit: true' and the 'sudo reboot' in you examples), you would not do that for any good reason.
> >
> > Typically, you would write something like
> >
> > 'My name is {firstname} {lastname}' interpolate.
> >
> > in a method of an object with firstname and lastname as instance variables. To access the binding, #evaluate: is used. Though a malicious person could enter 'Smalltalk snapshot:false andQuit: true' as name, it is not that expression that gets evaluated. So in that respect there is no risk.
> >
> > The risk would be when the template string itself would be (partially) based on used input.
> >
> > which is easy to overlook:
> >
> > aString interpolate
> >
> > People are on average a bit more carefull when they use #compile: or #evaluate:.
> >
> > Thierry
>
> 100% correct, hence my warning.
>
> > > Phil
> > >
> > > On Thu, Sep 28, 2017 at 4:43 PM, Sven Van Caekenberghe <sven(a)stfx.eu> wrote:
> > >
> > >
> > > > On 28 Sep 2017, at 16:27, phil(a)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 not provide a context, you just write the expressions inline. Compare the following two:
> > >
> > > 'Today is {1} format: { Date today }.
> > >
> > > 'Today is { Date today }' interpolate.
> > >
> > > > On Thu, Sep 28, 2017 at 4:20 PM, Sven Van Caekenberghe <sven(a)stfx.eu> wrote:
> > > > 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 := 123.
> > > > y := #foo.
> > > > 'x={1} and y={2}' format: { x. y }.
> > > >
> > > > It is also possible to use a dictionary with keys, like this:
> > > >
> > > > | x y |
> > > > x := 123.
> > > > y := #foo.
> > > > 'x={x} and y={y}' format: { #x->x. #y->y } asDictionary.
> > > >
> > > > But this is not true string interpolation as described in [ https://en.wikipedia.org/wiki/String_interpolation ]. The idea is to write the value generating expressions directly inside the strings.
> > > >
> > > > Since in Pharo we add features not by extending the syntax but by adding messages I wondered if it could be done for string interpolation. The goal is to make the following work:
> > > >
> > > > | x y |
> > > > x := 123.
> > > > y := #foo.
> > > > 'It seems x equals {x} and y equals {y} while Pi is still {Float pi}' interpolate.
> > > >
> > > > => 'It seems x equals 123 and y equals foo while Pi is still 3.141592653589793'
> > > >
> > > > Here is the implementation I came up with:
> > > >
> > > > String>>#interpolate
> > > > "Format the receiver by interpolating the evaluation of expressions
> > > > in between curly brackets in the context of the sender as in the following 3 oneline examples.
> > > > 'Today is {Date today}' interpolate.
> > > > | x | x := 123. 'x equals {x} and pi equals {Float pi}' interpolate.
> > > > 'In {#strings} you can escape \{ by prefixing it with \\' interpolate."
> > > >
> > > > | senderContext |
> > > > senderContext := thisContext sender.
> > > > ^ self class new: self size streamContents: [ :out | | stream |
> > > > stream := self readStream.
> > > > [ stream atEnd ] whileFalse: [ | currentChar |
> > > > (currentChar := stream next) == ${
> > > > ifTrue: [ | expression result |
> > > > expression := stream upTo: $}.
> > > > result := Compiler new
> > > > evaluate: expression in: senderContext to: nil notifying: nil ifFail: [ ^ nil ] logged: false.
> > > > out nextPutAll: result asString ]
> > > > ifFalse: [
> > > > currentChar == $\
> > > > ifTrue: [ stream atEnd ifFalse: [ out nextPut: stream next ] ]
> > > > ifFalse: [ out nextPut: currentChar ] ] ] ]
> > > >
> > > > It is a hack that could certainly be improved. And there is of course an obvious security problem.
> > > >
> > > > Thoughts ?
> > > >
> > > > Sven
> > > >
> > > >
> > > >
> > >
> > >
> > >
>
>
>
>
Sept. 28, 2017
Re: [Pharo-dev] [Ann] Class meta annotations
by Denis Kudriashov
2017-09-25 17:57 GMT+02:00 Denis Kudriashov <dionisiydk(a)gmail.com>:
> 2017-09-25 17:38 GMT+02:00 Stephane Ducasse <stepharo.self(a)gmail.com>:
>
>> I agree with guille. We should just called them class annotations.
>>
>> Denis what is a declared instance (is it an object returned by the method
>> having the annotation)
>> but can we find a better name.
>>
>
> My idea that the method with pragma #classMetaAnnotation is the
> declaration of annotation. Internally this declaration creates instance of
> specified annotation which cached by system. And users access all these
> declared instances for reflection purposes.
>
>
Maybe #registeredInstances would be better?
> Also annotation has inst var declarationSelector.
>
>
>> may be effectiveInstances?
>>
>
> I don't like this name. I not understand "effective" in that context.
>
>
>>
>>
>> On Mon, Sep 25, 2017 at 5:09 PM, Guillermo Polito <
>> guillermopolito(a)gmail.com> wrote:
>>
>>> Why calling them meta-annotation and not just annotation? Annotations
>>> are in general already meta :)
>>>
>>> On Mon, Sep 25, 2017 at 5:01 PM, Denis Kudriashov <dionisiydk(a)gmail.com>
>>> wrote:
>>>
>>>> Hi.
>>>>
>>>> I glad to present one class package which introduces reusable mechanism
>>>> for first class annotations.
>>>>
>>>> The project can be found on github https://github.com/dion
>>>> isiydk/ClassMetaAnnotation.
>>>> And I tried to describe why it is needed in my blog
>>>> http://dionisiydk.blogspot.fr/2017/09/class-meta-annotations.html.
>>>>
>>>> And here is overview:
>>>>
>>>> Every annotation should be subclass of ClassMetaAnnotation. To attach
>>>> it to class you create new class side method which will return an instance
>>>> of the annotation. Method should be marked with pragma #classMetaAnnotation:
>>>>
>>>>
>>>> MyClass class>>specialAnnotation
>>>>
>>>> <classMetaAnnotation>
>>>>
>>>> ^MySpecialAnnotation new
>>>>
>>>>
>>>> To query annotations from system there are two methods:
>>>>
>>>> 1) You can ask concrete annotation class for all declared instances:
>>>>
>>>> MySpecialAnnotation declaredInstances
>>>>
>>>> 2) You can ask given class for all attached annotations:
>>>>
>>>> MyClass metaAnnotations
>>>>
>>>> Every annotation includes information about annotated class and the
>>>> selector of declaring method.
>>>> All annotations are cached. So it is cheap to query them. There are
>>>> extra messages to enumerate annotations using block.
>>>>
>>>> Now let's discuss it. I think it can be good addition for the Pharo 7.
>>>> Especially that it is very small code.
>>>>
>>>> Also I would like to thank Marcus who helps me realize this concept in
>>>> Commander and Calypso which I start simplify with this library.
>>>>
>>>> Best regards,
>>>> Denis
>>>>
>>>
>>>
>>>
>>> --
>>>
>>>
>>>
>>> Guille Polito
>>>
>>> Research Engineer
>>>
>>> Centre de Recherche en Informatique, Signal et Automatique de Lille
>>>
>>> CRIStAL - UMR 9189
>>>
>>> French National Center for Scientific Research - *http://www.cnrs.fr
>>> <http://www.cnrs.fr>*
>>>
>>>
>>> *Web:* *http://guillep.github.io* <http://guillep.github.io>
>>>
>>> *Phone: *+33 06 52 70 66 13 <+33%206%2052%2070%2066%2013>
>>>
>>
>>
>
Sept. 28, 2017
Re: [Pharo-dev] String Interpolation
by 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: Character tab ) explode: Character tab =
an OrderedCollection(#(1 2) #(3 4))
'abcdef' explode: 'cd' = an OrderedCollection('ab' 'ef')"
| resultCollection starting aDelimiterPosition aDelimiterSize |
self ifEmpty: [^self].
resultCollection := OrderedCollection new.
aDelimiterSize := aDelimiter isCollection ifTrue: [aDelimiter size]
ifFalse: [1].
starting := 1.
[aDelimiterPosition := aDelimiter isCollection ifTrue: [self
indexOfSubCollection: aDelimiter startingAt: starting] ifFalse: [self
indexOf: aDelimiter startingAt: starting ifAbsent: [0]].
aDelimiterPosition > 0] whileTrue: [
resultCollection add: (self copyFrom: starting to: aDelimiterPosition - 1).
starting := aDelimiterPosition + aDelimiterSize.
].
resultCollection add: (self copyFrom: starting to: self size).
^resultCollection
Collection >> mergeDelimited: anObject
"return to reciever a collection with each element concatenated to remove
imbeded collections"
"#(#(1 2) #(3 4)) mergeDelimited: Character tab = #(1 2 Character tab 3
4), #('ab' 'cd') mergeDelimited: Character cr = 'ab
cd' "
| returnCollection aSeperator |
self ifEmpty: [^self].
aSeperator := anObject isCollection ifTrue: [anObject] ifFalse: [Array
with: anObject].
returnCollection := self first species new.
self copy from: 1 to: self size -1 do: [:a |
a ifNotNil: [
returnCollection := returnCollection, a, aSeperator
].
].
^returnCollection, self last
On Thu, Sep 28, 2017 at 11:25 AM, Sven Van Caekenberghe <sven(a)stfx.eu>
wrote:
>
>
> > On 28 Sep 2017, at 17:13, Thierry Goubier <thierry.goubier(a)gmail.com>
> wrote:
> >
> >
> >
> > 2017-09-28 17:08 GMT+02:00 Sven Van Caekenberghe <sven(a)stfx.eu>:
> >
> >
> > > On 28 Sep 2017, at 16:58, phil(a)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 is always the original programmer who writes the template
> (including the 'Smalltalk snapshot:false andQuit: true' and the 'sudo
> reboot' in you examples), you would not do that for any good reason.
> >
> > Typically, you would write something like
> >
> > 'My name is {firstname} {lastname}' interpolate.
> >
> > in a method of an object with firstname and lastname as instance
> variables. To access the binding, #evaluate: is used. Though a malicious
> person could enter 'Smalltalk snapshot:false andQuit: true' as name, it is
> not that expression that gets evaluated. So in that respect there is no
> risk.
> >
> > The risk would be when the template string itself would be (partially)
> based on used input.
> >
> > which is easy to overlook:
> >
> > aString interpolate
> >
> > People are on average a bit more carefull when they use #compile: or
> #evaluate:.
> >
> > Thierry
>
> 100% correct, hence my warning.
>
> > > Phil
> > >
> > > On Thu, Sep 28, 2017 at 4:43 PM, Sven Van Caekenberghe <sven(a)stfx.eu>
> wrote:
> > >
> > >
> > > > On 28 Sep 2017, at 16:27, phil(a)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 not
> provide a context, you just write the expressions inline. Compare the
> following two:
> > >
> > > 'Today is {1} format: { Date today }.
> > >
> > > 'Today is { Date today }' interpolate.
> > >
> > > > On Thu, Sep 28, 2017 at 4:20 PM, Sven Van Caekenberghe <sven(a)stfx.eu>
> wrote:
> > > > 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 := 123.
> > > > y := #foo.
> > > > 'x={1} and y={2}' format: { x. y }.
> > > >
> > > > It is also possible to use a dictionary with keys, like this:
> > > >
> > > > | x y |
> > > > x := 123.
> > > > y := #foo.
> > > > 'x={x} and y={y}' format: { #x->x. #y->y } asDictionary.
> > > >
> > > > But this is not true string interpolation as described in [
> https://en.wikipedia.org/wiki/String_interpolation ]. The idea is to
> write the value generating expressions directly inside the strings.
> > > >
> > > > Since in Pharo we add features not by extending the syntax but by
> adding messages I wondered if it could be done for string interpolation.
> The goal is to make the following work:
> > > >
> > > > | x y |
> > > > x := 123.
> > > > y := #foo.
> > > > 'It seems x equals {x} and y equals {y} while Pi is still {Float
> pi}' interpolate.
> > > >
> > > > => 'It seems x equals 123 and y equals foo while Pi is still
> 3.141592653589793'
> > > >
> > > > Here is the implementation I came up with:
> > > >
> > > > String>>#interpolate
> > > > "Format the receiver by interpolating the evaluation of expressions
> > > > in between curly brackets in the context of the sender as in the
> following 3 oneline examples.
> > > > 'Today is {Date today}' interpolate.
> > > > | x | x := 123. 'x equals {x} and pi equals {Float pi}'
> interpolate.
> > > > 'In {#strings} you can escape \{ by prefixing it with \\'
> interpolate."
> > > >
> > > > | senderContext |
> > > > senderContext := thisContext sender.
> > > > ^ self class new: self size streamContents: [ :out | | stream |
> > > > stream := self readStream.
> > > > [ stream atEnd ] whileFalse: [ | currentChar |
> > > > (currentChar := stream next) == ${
> > > > ifTrue: [ | expression result |
> > > > expression := stream upTo: $}.
> > > > result := Compiler new
> > > > evaluate: expression in: senderContext to: nil
> notifying: nil ifFail: [ ^ nil ] logged: false.
> > > > out nextPutAll: result asString ]
> > > > ifFalse: [
> > > > currentChar == $\
> > > > ifTrue: [ stream atEnd ifFalse: [ out nextPut: stream
> next ] ]
> > > > ifFalse: [ out nextPut: currentChar ] ] ] ]
> > > >
> > > > It is a hack that could certainly be improved. And there is of
> course an obvious security problem.
> > > >
> > > > Thoughts ?
> > > >
> > > > Sven
> > > >
> > > >
> > > >
> > >
> > >
> > >
>
>
>
>
Sept. 28, 2017
Re: [Pharo-dev] String Interpolation
by phil@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 should be toroughly sanitized and
always considered dangerous.
So, maybe a TaintedString and TaintedWideString could be introducted with
an #isTainted returing true where Object>>#isTainted would be returning
false and being overriden in Collection to check if anything that is in the
collection is tainted as well.
So one would not be allowed to interpolate tainted variables.
There is more to this but you get the idea
Maybe the VM could be supporting this. We have immutable, so why not
tainted?
Phil
On Thu, Sep 28, 2017 at 5:25 PM, Sven Van Caekenberghe <sven(a)stfx.eu> wrote:
>
>
> > On 28 Sep 2017, at 17:13, Thierry Goubier <thierry.goubier(a)gmail.com>
> wrote:
> >
> >
> >
> > 2017-09-28 17:08 GMT+02:00 Sven Van Caekenberghe <sven(a)stfx.eu>:
> >
> >
> > > On 28 Sep 2017, at 16:58, phil(a)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 is always the original programmer who writes the template
> (including the 'Smalltalk snapshot:false andQuit: true' and the 'sudo
> reboot' in you examples), you would not do that for any good reason.
> >
> > Typically, you would write something like
> >
> > 'My name is {firstname} {lastname}' interpolate.
> >
> > in a method of an object with firstname and lastname as instance
> variables. To access the binding, #evaluate: is used. Though a malicious
> person could enter 'Smalltalk snapshot:false andQuit: true' as name, it is
> not that expression that gets evaluated. So in that respect there is no
> risk.
> >
> > The risk would be when the template string itself would be (partially)
> based on used input.
> >
> > which is easy to overlook:
> >
> > aString interpolate
> >
> > People are on average a bit more carefull when they use #compile: or
> #evaluate:.
> >
> > Thierry
>
> 100% correct, hence my warning.
>
> > > Phil
> > >
> > > On Thu, Sep 28, 2017 at 4:43 PM, Sven Van Caekenberghe <sven(a)stfx.eu>
> wrote:
> > >
> > >
> > > > On 28 Sep 2017, at 16:27, phil(a)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 not
> provide a context, you just write the expressions inline. Compare the
> following two:
> > >
> > > 'Today is {1} format: { Date today }.
> > >
> > > 'Today is { Date today }' interpolate.
> > >
> > > > On Thu, Sep 28, 2017 at 4:20 PM, Sven Van Caekenberghe <sven(a)stfx.eu>
> wrote:
> > > > 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 := 123.
> > > > y := #foo.
> > > > 'x={1} and y={2}' format: { x. y }.
> > > >
> > > > It is also possible to use a dictionary with keys, like this:
> > > >
> > > > | x y |
> > > > x := 123.
> > > > y := #foo.
> > > > 'x={x} and y={y}' format: { #x->x. #y->y } asDictionary.
> > > >
> > > > But this is not true string interpolation as described in [
> https://en.wikipedia.org/wiki/String_interpolation ]. The idea is to
> write the value generating expressions directly inside the strings.
> > > >
> > > > Since in Pharo we add features not by extending the syntax but by
> adding messages I wondered if it could be done for string interpolation.
> The goal is to make the following work:
> > > >
> > > > | x y |
> > > > x := 123.
> > > > y := #foo.
> > > > 'It seems x equals {x} and y equals {y} while Pi is still {Float
> pi}' interpolate.
> > > >
> > > > => 'It seems x equals 123 and y equals foo while Pi is still
> 3.141592653589793'
> > > >
> > > > Here is the implementation I came up with:
> > > >
> > > > String>>#interpolate
> > > > "Format the receiver by interpolating the evaluation of expressions
> > > > in between curly brackets in the context of the sender as in the
> following 3 oneline examples.
> > > > 'Today is {Date today}' interpolate.
> > > > | x | x := 123. 'x equals {x} and pi equals {Float pi}'
> interpolate.
> > > > 'In {#strings} you can escape \{ by prefixing it with \\'
> interpolate."
> > > >
> > > > | senderContext |
> > > > senderContext := thisContext sender.
> > > > ^ self class new: self size streamContents: [ :out | | stream |
> > > > stream := self readStream.
> > > > [ stream atEnd ] whileFalse: [ | currentChar |
> > > > (currentChar := stream next) == ${
> > > > ifTrue: [ | expression result |
> > > > expression := stream upTo: $}.
> > > > result := Compiler new
> > > > evaluate: expression in: senderContext to: nil
> notifying: nil ifFail: [ ^ nil ] logged: false.
> > > > out nextPutAll: result asString ]
> > > > ifFalse: [
> > > > currentChar == $\
> > > > ifTrue: [ stream atEnd ifFalse: [ out nextPut: stream
> next ] ]
> > > > ifFalse: [ out nextPut: currentChar ] ] ] ]
> > > >
> > > > It is a hack that could certainly be improved. And there is of
> course an obvious security problem.
> > > >
> > > > Thoughts ?
> > > >
> > > > Sven
> > > >
> > > >
> > > >
> > >
> > >
> > >
>
>
>
Sept. 28, 2017