Pharo-users
By thread
pharo-users@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
March 2018
- 74 participants
- 500 messages
Re: [Pharo-users] Packaging question
by Gabriel Cotelli
I will use one Baseline with several groups. And choose to load by default
(if only runtime support or runtime plus generator)
On Tue, Mar 13, 2018 at 3:02 PM, Stephane Ducasse <stepharo.self(a)gmail.com>
wrote:
> Hi
>
> I'm developing a small library named Chrysal (to be announced when
> ready - the successor of Cocoon) that supports configuration files
> (and conversion of strings into our lovely objects).
>
> The idea is that based on description objects, a class is generated
> statically with all the conversion logic.
> Now a configuration for an App is a subclass of one minimal class
> called ChrysalConfiguration.
> and this class is packaged into the ChrysalRuntime package this is the
> only thing needed (I could remove it by automatically recompiling even
> more code but looks a bit terrible at the end).
>
> Now my question.
> Should I propose two BaselineOfs? One for the Generator and one for the
> Runtime?
> I thought so. And generator should depend on the runtime.
>
> Stef
>
>
March 13, 2018
Re: [Pharo-users] About handling strings in streams with STON
by Stephane Ducasse
Sven I was thinking about the API
you could you have a variant of put: onStream: that put the printed
version of the argument.
Because this is what I thought it was doing.
Stef
On Tue, Mar 13, 2018 at 6:32 PM, Sven Van Caekenberghe <sven(a)stfx.eu> wrote:
>
>
>> On 13 Mar 2018, at 18:09, Stephane Ducasse <stepharo.self(a)gmail.com> wrote:
>>
>> I originally did
>>
>> addDescriptionMethodBodyIn: aStream forItems: descriptionItems
>> aStream nextPutAll: 'STON fromString: '.
>> STON put: descriptionItems onStream: aStream
>>
>>
>> and I get
>>
>> STON fromString:
>> [StringConfigurationItem{#propertyName:'title',#default:'my super cool
>> book'},BooleanConfigurationItem{#propertyName:'verbose',#default:'true'},StringConfigurationItem{#propertyName:'attribution',#default:'me,
>> myself and I'},StringConfigurationItem{#propertyName:'series',#default:'Square
>> Bracket Associate
>> Collection'},StringConfigurationItem{#propertyName:'keywords',#default:'Pharo'},FolderConfigurationItem{#propertyName:'outputDirectory',#default:'build'},FileConfigurationItem{#propertyName:'mainDocument',#default:'book'},FileConfigurationItem{#propertyName:'latexTemplate',#default:'_support/templates/main.latex.mustache'},FileConfigurationItem{#propertyName:'latexChapterTemplate',#default:'_support/templates/chapter.latex.mustache'},FileConfigurationItem{#propertyName:'htmlTemplate',#default:'_support/templates/html.mustache'},FileConfigurationItem{#propertyName:'htmlChapterTemplate',#default:'_support/templates/html.mustache'},NewLineConfigurationItem{#propertyName:'newLine',#defaultKey:#unix},SymbolConfigurationItem{#propertyName:'latexWriter',#default:#'latex:sbabook'}]
>>
>> I see that you pass via a string and me via a stream but I wonder why
>> with my solution strings where not escaped.
>
> You're sick that is why you are not thinking clearly ;-)
>
> This has nothing to do with STON, but with Smalltalk syntax.
>
> Say you want to write out a Date creation expression, then the following (what you do) would not work:
>
> Compiler evaluate: (String streamContents: [ :out |
> out << 'Date fromString: '.
> Date today printOn: out ]).
>
> But the following does (as I did):
>
> Compiler evaluate: (String streamContents: [ :out |
> out << 'Date fromString: '.
> out print: Date today printString ]).
>
> You need to take the printed representation and turn it into a Smalltalk String literal. If you just put it there, all the characters will be there but the string will not be quoted, nor will embedded quotes be escaped properly.
>
>> Stef
>>
>> On Tue, Mar 13, 2018 at 5:13 PM, Stephane Ducasse
>> <stepharo.self(a)gmail.com> wrote:
>>> On Tue, Mar 13, 2018 at 5:12 PM, Stephane Ducasse
>>> <stepharo.self(a)gmail.com> wrote:
>>>> Tx sven got caught by a flu... freezing in my bed.
>>>> I will check.
>>>>
>>>> On Mon, Mar 12, 2018 at 11:01 PM, Sven Van Caekenberghe <sven(a)stfx.eu> wrote:
>>>>> So I guess that you want a Smalltalk expression that, when evaluated, returns an arbitrary STON-ified object as a real object.
>>>>>
>>>>> Let's say you want to STON-ify the following object:
>>>>>
>>>>> { #firstName->'Stéphane'. #lastName->'Ducasse'. #note->'Look: '', that was a single quote.' } asDictionary.
>>>>>
>>>>> Note there is a single quote character inside the #note.
>>>>>
>>>>> You can do that using #print: when needed. Here is an expression to see how that works:
>>>>>
>>>>> Compiler evaluate: (String streamContents: [ :out |
>>>>> out
>>>>> nextPutAll: 'STON fromString: ';
>>>>> print: (STON toString: ({ #firstName->'Stéphane'. #lastName->'Ducasse'. #note->'Look: '', that was a single quote.' } asDictionary)) ]).
>>>>>
>>>>> The Smalltalk expression then looks like this:
>>>>>
>>>>> STON fromString: '{#note:''Look: \'', that was a single quote.'',#firstName:''Stéphane'',#lastName:''Ducasse''}'
>>>>>
>>>>> The double single quotes are Smalltalk's syntax's escaping, while the backslashes are STON's. Yes, that is a bit confusing, but consistent.
>>>>>
>>>>> Is this what you need ?
>>>>>
>>>>>> On 12 Mar 2018, at 22:43, Stephane Ducasse <stepharo.self(a)gmail.com> wrote:
>>>>>>
>>>>>> Hi
>>>>>>
>>>>>> I want to write a method that generate a method that when I execute
>>>>>> this recreates the objects that I STONified.
>>>>>> (I love STON).
>>>>>>
>>>>>> So I did something like that
>>>>>>
>>>>>> descriptionMethodFrom: descriptionItems
>>>>>> "self new descriptionMethodFrom: ChrysalConfigurationDescription
>>>>>> itemDescriptionForXX"
>>>>>>
>>>>>> ^ String streamContents: [ :s |
>>>>>> s nextPutAll: 'descriptions'; cr.
>>>>>> s nextPutAll: '^ STON fromString: '.
>>>>>> s nextPutAll: (STON toStringPretty: descriptionItems) ]
>>>>>>
>>>>>> and I get of course something wrong :) because the strings are not
>>>>>> doubel quoted and the first expression is not surrounded by single
>>>>>> quote.
>>>>>>
>>>>>> And I could do it but I want a smart way to do it. I was thinking that
>>>>>> may be I'm missing something obvious.
>>>>>>
>>>>>> descriptions
>>>>>> ^ STON fromString: [
>>>>>> StringConfigurationItem {
>>>>>> #propertyName : 'title',
>>>>>> #default : 'my super cool book'
>>>>>> },
>>>>>> BooleanConfigurationItem {
>>>>>> #propertyName : 'verbose',
>>>>>> #default : 'true'
>>>>>> },
>>>>>> StringConfigurationItem {
>>>>>> #propertyName : 'attribution',
>>>>>> #default : 'me, myself and I'
>>>>>> },
>>>>>> StringConfigurationItem {
>>>>>> #propertyName : 'series',
>>>>>> #default : 'Square Bracket Associate Collection'
>>>>>> }
>>>>>> ]
>>>>>>
>>>>>
>>>>>
>>
>
>
March 13, 2018
Re: [Pharo-users] About handling strings in streams with STON
by Stephane Ducasse
>
> Say you want to write out a Date creation expression, then the following (what you do) would not work:
>
> Compiler evaluate: (String streamContents: [ :out |
> out << 'Date fromString: '.
> Date today printOn: out ]).
>
> But the following does (as I did):
>
> Compiler evaluate: (String streamContents: [ :out |
> out << 'Date fromString: '.
> out print: Date today printString ]).
>
> You need to take the printed representation and turn it into a Smalltalk String literal. If you just put it there, all the characters will be there but the string will not be quoted, nor will embedded quotes be escaped properly.
Yes I thought about it. I was thinking that we are pretty low-level
for template programming.
May be RBrewritter is the way to go.
March 13, 2018
Re: [Pharo-users] Ever growing image
by Stephane Ducasse
Hilaire
I do not have the answer and I do not know but you should have a look
at the bash script.
Because this is where the logic is. I will discuss tomorrow with
guille (right now I'm sick).
Stef
On Mon, Mar 12, 2018 at 9:34 PM, Hilaire <hilaire(a)drgeo.eu> wrote:
> Le 12/03/2018 à 10:16, Guillermo Polito a écrit :
>>
>> That said, I would also like to have a smaller and more malleable system,
>> in that I agree with you, but that takes time and work, and I see few people
>> that is diving in the insides of Pharo to help get us something in that
>> direction. Not because they don't care but because it is difficult and time
>> consuming.
>
>
> Which direction should I follow after building a boostrap image following
> these instructions
> https://github.com/pharo-project/pharo#bootstrapping-pharo-from-sources ?
>
>
> --
> Dr. Geo
> http://drgeo.eu
>
>
>
March 13, 2018
Re: [Pharo-users] Pharo-users] SSL Exception when installing DataFrame
by Stephane Ducasse
I know that Hayatou got the same error while trying to load DataFrame.
Here is what he told me
I use to load DataFrame on Pharo6.1 with Linux it work well
But on Windows 7 Ãdition Intégrale 64-bit (6.1, Build 7600)
(7600.win7_gdr.110622-1503) with Pharo6.1 it not working. But with
Pharo5 on the same windows 7 it work well
On Tue, Mar 13, 2018 at 10:36 AM, Baveco, Hans <hans.baveco(a)wur.nl> wrote:
> I get the same error when trying to install other packages (e.g. Cruiser)
> (SSL Exception: connect failed [code:-5]),
>
> Also when trying to do a software update from the System menu.
>
> This is Pharo 6.1 on windows 7
>
>
>
> It might be somehow related to Iceberg: the Iceberg item in the World menu
> has gone after trying to update??
>
> Hans
>
>
>
>
>
>
March 13, 2018
Packaging question
by Stephane Ducasse
Hi
I'm developing a small library named Chrysal (to be announced when
ready - the successor of Cocoon) that supports configuration files
(and conversion of strings into our lovely objects).
The idea is that based on description objects, a class is generated
statically with all the conversion logic.
Now a configuration for an App is a subclass of one minimal class
called ChrysalConfiguration.
and this class is packaged into the ChrysalRuntime package this is the
only thing needed (I could remove it by automatically recompiling even
more code but looks a bit terrible at the end).
Now my question.
Should I propose two BaselineOfs? One for the Generator and one for the Runtime?
I thought so. And generator should depend on the runtime.
Stef
March 13, 2018
Re: [Pharo-users] About handling strings in streams with STON
by Stephane Ducasse
And my string is just so it is plain normal but when I do not STON
fromString: .... I get 47 elements instead of 13. When I do it
manually I get of course 13.
But the test failed with 47 :)
'[
StringConfigurationItem {
#propertyName : ''title'',
#default : ''my super cool book''
},
BooleanConfigurationItem {
#propertyName : ''verbose'',
#default : ''true''
},
StringConfigurationItem {
#propertyName : ''attribution'',
#default : ''me, myself and I''
},
StringConfigurationItem {
#propertyName : ''series'',
#default : ''Square Bracket Associate Collection''
},
StringConfigurationItem {
#propertyName : ''keywords'',
#default : ''Pharo''
},
FolderConfigurationItem {
#propertyName : ''outputDirectory'',
#default : ''build''
},
FileConfigurationItem {
#propertyName : ''mainDocument'',
#default : ''book''
},
FileConfigurationItem {
#propertyName : ''latexTemplate'',
#default : ''_support/templates/main.latex.mustache''
},
FileConfigurationItem {
#propertyName : ''latexChapterTemplate'',
#default : ''_support/templates/chapter.latex.mustache''
},
FileConfigurationItem {
#propertyName : ''htmlTemplate'',
#default : ''_support/templates/html.mustache''
},
FileConfigurationItem {
#propertyName : ''htmlChapterTemplate'',
#default : ''_support/templates/html.mustache''
},
NewLineConfigurationItem {
#propertyName : ''newLine'',
#defaultKey : #unix
},
SymbolConfigurationItem {
#propertyName : ''latexWriter'',
#default : #''latex:sbabook''
}
]'
On Tue, Mar 13, 2018 at 6:35 PM, Stephane Ducasse
<stepharo.self(a)gmail.com> wrote:
> Now I did
>
> addDescriptionBodyIn: aStream forItems: descriptionItems
> aStream print: (STON toStringPretty: descriptionItems)
>
> and it works sometimes.
>
> testDescriptionBuilder
> | builder string |
> builder := ChrysalConfigurationBuilder new.
> string := String
> streamContents: [ :s | builder
>
> addDescriptionBodyIn: s
> forItems:
> ChrysalConfigurationDescription itemDescriptionForXX ].
> self
> assert: (STON fromString: string) size
> equals: ChrysalConfigurationDescription itemDescriptionForXX size
>
>
> And I have no idea why I get 47 and 13 instead of 13 and 13. This is
> super super strange.
>
> Stef
>
> On Tue, Mar 13, 2018 at 6:09 PM, Stephane Ducasse
> <stepharo.self(a)gmail.com> wrote:
>> I originally did
>>
>> addDescriptionMethodBodyIn: aStream forItems: descriptionItems
>> aStream nextPutAll: 'STON fromString: '.
>> STON put: descriptionItems onStream: aStream
>>
>>
>> and I get
>>
>> STON fromString:
>> [StringConfigurationItem{#propertyName:'title',#default:'my super cool
>> book'},BooleanConfigurationItem{#propertyName:'verbose',#default:'true'},StringConfigurationItem{#propertyName:'attribution',#default:'me,
>> myself and I'},StringConfigurationItem{#propertyName:'series',#default:'Square
>> Bracket Associate
>> Collection'},StringConfigurationItem{#propertyName:'keywords',#default:'Pharo'},FolderConfigurationItem{#propertyName:'outputDirectory',#default:'build'},FileConfigurationItem{#propertyName:'mainDocument',#default:'book'},FileConfigurationItem{#propertyName:'latexTemplate',#default:'_support/templates/main.latex.mustache'},FileConfigurationItem{#propertyName:'latexChapterTemplate',#default:'_support/templates/chapter.latex.mustache'},FileConfigurationItem{#propertyName:'htmlTemplate',#default:'_support/templates/html.mustache'},FileConfigurationItem{#propertyName:'htmlChapterTemplate',#default:'_support/templates/html.mustache'},NewLineConfigurationItem{#propertyName:'newLine',#defaultKey:#unix},SymbolConfigurationItem{#propertyName:'latexWriter',#default:#'latex:sbabook'}]
>>
>> I see that you pass via a string and me via a stream but I wonder why
>> with my solution strings where not escaped.
>>
>>
>>
>> Stef
>>
>> On Tue, Mar 13, 2018 at 5:13 PM, Stephane Ducasse
>> <stepharo.self(a)gmail.com> wrote:
>>> On Tue, Mar 13, 2018 at 5:12 PM, Stephane Ducasse
>>> <stepharo.self(a)gmail.com> wrote:
>>>> Tx sven got caught by a flu... freezing in my bed.
>>>> I will check.
>>>>
>>>> On Mon, Mar 12, 2018 at 11:01 PM, Sven Van Caekenberghe <sven(a)stfx.eu> wrote:
>>>>> So I guess that you want a Smalltalk expression that, when evaluated, returns an arbitrary STON-ified object as a real object.
>>>>>
>>>>> Let's say you want to STON-ify the following object:
>>>>>
>>>>> { #firstName->'Stéphane'. #lastName->'Ducasse'. #note->'Look: '', that was a single quote.' } asDictionary.
>>>>>
>>>>> Note there is a single quote character inside the #note.
>>>>>
>>>>> You can do that using #print: when needed. Here is an expression to see how that works:
>>>>>
>>>>> Compiler evaluate: (String streamContents: [ :out |
>>>>> out
>>>>> nextPutAll: 'STON fromString: ';
>>>>> print: (STON toString: ({ #firstName->'Stéphane'. #lastName->'Ducasse'. #note->'Look: '', that was a single quote.' } asDictionary)) ]).
>>>>>
>>>>> The Smalltalk expression then looks like this:
>>>>>
>>>>> STON fromString: '{#note:''Look: \'', that was a single quote.'',#firstName:''Stéphane'',#lastName:''Ducasse''}'
>>>>>
>>>>> The double single quotes are Smalltalk's syntax's escaping, while the backslashes are STON's. Yes, that is a bit confusing, but consistent.
>>>>>
>>>>> Is this what you need ?
>>>>>
>>>>>> On 12 Mar 2018, at 22:43, Stephane Ducasse <stepharo.self(a)gmail.com> wrote:
>>>>>>
>>>>>> Hi
>>>>>>
>>>>>> I want to write a method that generate a method that when I execute
>>>>>> this recreates the objects that I STONified.
>>>>>> (I love STON).
>>>>>>
>>>>>> So I did something like that
>>>>>>
>>>>>> descriptionMethodFrom: descriptionItems
>>>>>> "self new descriptionMethodFrom: ChrysalConfigurationDescription
>>>>>> itemDescriptionForXX"
>>>>>>
>>>>>> ^ String streamContents: [ :s |
>>>>>> s nextPutAll: 'descriptions'; cr.
>>>>>> s nextPutAll: '^ STON fromString: '.
>>>>>> s nextPutAll: (STON toStringPretty: descriptionItems) ]
>>>>>>
>>>>>> and I get of course something wrong :) because the strings are not
>>>>>> doubel quoted and the first expression is not surrounded by single
>>>>>> quote.
>>>>>>
>>>>>> And I could do it but I want a smart way to do it. I was thinking that
>>>>>> may be I'm missing something obvious.
>>>>>>
>>>>>> descriptions
>>>>>> ^ STON fromString: [
>>>>>> StringConfigurationItem {
>>>>>> #propertyName : 'title',
>>>>>> #default : 'my super cool book'
>>>>>> },
>>>>>> BooleanConfigurationItem {
>>>>>> #propertyName : 'verbose',
>>>>>> #default : 'true'
>>>>>> },
>>>>>> StringConfigurationItem {
>>>>>> #propertyName : 'attribution',
>>>>>> #default : 'me, myself and I'
>>>>>> },
>>>>>> StringConfigurationItem {
>>>>>> #propertyName : 'series',
>>>>>> #default : 'Square Bracket Associate Collection'
>>>>>> }
>>>>>> ]
>>>>>>
>>>>>
>>>>>
March 13, 2018
Re: [Pharo-users] About handling strings in streams with STON
by Stephane Ducasse
Now I did
addDescriptionBodyIn: aStream forItems: descriptionItems
aStream print: (STON toStringPretty: descriptionItems)
and it works sometimes.
testDescriptionBuilder
| builder string |
builder := ChrysalConfigurationBuilder new.
string := String
streamContents: [ :s | builder
addDescriptionBodyIn: s
forItems:
ChrysalConfigurationDescription itemDescriptionForXX ].
self
assert: (STON fromString: string) size
equals: ChrysalConfigurationDescription itemDescriptionForXX size
And I have no idea why I get 47 and 13 instead of 13 and 13. This is
super super strange.
Stef
On Tue, Mar 13, 2018 at 6:09 PM, Stephane Ducasse
<stepharo.self(a)gmail.com> wrote:
> I originally did
>
> addDescriptionMethodBodyIn: aStream forItems: descriptionItems
> aStream nextPutAll: 'STON fromString: '.
> STON put: descriptionItems onStream: aStream
>
>
> and I get
>
> STON fromString:
> [StringConfigurationItem{#propertyName:'title',#default:'my super cool
> book'},BooleanConfigurationItem{#propertyName:'verbose',#default:'true'},StringConfigurationItem{#propertyName:'attribution',#default:'me,
> myself and I'},StringConfigurationItem{#propertyName:'series',#default:'Square
> Bracket Associate
> Collection'},StringConfigurationItem{#propertyName:'keywords',#default:'Pharo'},FolderConfigurationItem{#propertyName:'outputDirectory',#default:'build'},FileConfigurationItem{#propertyName:'mainDocument',#default:'book'},FileConfigurationItem{#propertyName:'latexTemplate',#default:'_support/templates/main.latex.mustache'},FileConfigurationItem{#propertyName:'latexChapterTemplate',#default:'_support/templates/chapter.latex.mustache'},FileConfigurationItem{#propertyName:'htmlTemplate',#default:'_support/templates/html.mustache'},FileConfigurationItem{#propertyName:'htmlChapterTemplate',#default:'_support/templates/html.mustache'},NewLineConfigurationItem{#propertyName:'newLine',#defaultKey:#unix},SymbolConfigurationItem{#propertyName:'latexWriter',#default:#'latex:sbabook'}]
>
> I see that you pass via a string and me via a stream but I wonder why
> with my solution strings where not escaped.
>
>
>
> Stef
>
> On Tue, Mar 13, 2018 at 5:13 PM, Stephane Ducasse
> <stepharo.self(a)gmail.com> wrote:
>> On Tue, Mar 13, 2018 at 5:12 PM, Stephane Ducasse
>> <stepharo.self(a)gmail.com> wrote:
>>> Tx sven got caught by a flu... freezing in my bed.
>>> I will check.
>>>
>>> On Mon, Mar 12, 2018 at 11:01 PM, Sven Van Caekenberghe <sven(a)stfx.eu> wrote:
>>>> So I guess that you want a Smalltalk expression that, when evaluated, returns an arbitrary STON-ified object as a real object.
>>>>
>>>> Let's say you want to STON-ify the following object:
>>>>
>>>> { #firstName->'Stéphane'. #lastName->'Ducasse'. #note->'Look: '', that was a single quote.' } asDictionary.
>>>>
>>>> Note there is a single quote character inside the #note.
>>>>
>>>> You can do that using #print: when needed. Here is an expression to see how that works:
>>>>
>>>> Compiler evaluate: (String streamContents: [ :out |
>>>> out
>>>> nextPutAll: 'STON fromString: ';
>>>> print: (STON toString: ({ #firstName->'Stéphane'. #lastName->'Ducasse'. #note->'Look: '', that was a single quote.' } asDictionary)) ]).
>>>>
>>>> The Smalltalk expression then looks like this:
>>>>
>>>> STON fromString: '{#note:''Look: \'', that was a single quote.'',#firstName:''Stéphane'',#lastName:''Ducasse''}'
>>>>
>>>> The double single quotes are Smalltalk's syntax's escaping, while the backslashes are STON's. Yes, that is a bit confusing, but consistent.
>>>>
>>>> Is this what you need ?
>>>>
>>>>> On 12 Mar 2018, at 22:43, Stephane Ducasse <stepharo.self(a)gmail.com> wrote:
>>>>>
>>>>> Hi
>>>>>
>>>>> I want to write a method that generate a method that when I execute
>>>>> this recreates the objects that I STONified.
>>>>> (I love STON).
>>>>>
>>>>> So I did something like that
>>>>>
>>>>> descriptionMethodFrom: descriptionItems
>>>>> "self new descriptionMethodFrom: ChrysalConfigurationDescription
>>>>> itemDescriptionForXX"
>>>>>
>>>>> ^ String streamContents: [ :s |
>>>>> s nextPutAll: 'descriptions'; cr.
>>>>> s nextPutAll: '^ STON fromString: '.
>>>>> s nextPutAll: (STON toStringPretty: descriptionItems) ]
>>>>>
>>>>> and I get of course something wrong :) because the strings are not
>>>>> doubel quoted and the first expression is not surrounded by single
>>>>> quote.
>>>>>
>>>>> And I could do it but I want a smart way to do it. I was thinking that
>>>>> may be I'm missing something obvious.
>>>>>
>>>>> descriptions
>>>>> ^ STON fromString: [
>>>>> StringConfigurationItem {
>>>>> #propertyName : 'title',
>>>>> #default : 'my super cool book'
>>>>> },
>>>>> BooleanConfigurationItem {
>>>>> #propertyName : 'verbose',
>>>>> #default : 'true'
>>>>> },
>>>>> StringConfigurationItem {
>>>>> #propertyName : 'attribution',
>>>>> #default : 'me, myself and I'
>>>>> },
>>>>> StringConfigurationItem {
>>>>> #propertyName : 'series',
>>>>> #default : 'Square Bracket Associate Collection'
>>>>> }
>>>>> ]
>>>>>
>>>>
>>>>
March 13, 2018
Re: [Pharo-users] About handling strings in streams with STON
by Sven Van Caekenberghe
> On 13 Mar 2018, at 18:09, Stephane Ducasse <stepharo.self(a)gmail.com> wrote:
>
> I originally did
>
> addDescriptionMethodBodyIn: aStream forItems: descriptionItems
> aStream nextPutAll: 'STON fromString: '.
> STON put: descriptionItems onStream: aStream
>
>
> and I get
>
> STON fromString:
> [StringConfigurationItem{#propertyName:'title',#default:'my super cool
> book'},BooleanConfigurationItem{#propertyName:'verbose',#default:'true'},StringConfigurationItem{#propertyName:'attribution',#default:'me,
> myself and I'},StringConfigurationItem{#propertyName:'series',#default:'Square
> Bracket Associate
> Collection'},StringConfigurationItem{#propertyName:'keywords',#default:'Pharo'},FolderConfigurationItem{#propertyName:'outputDirectory',#default:'build'},FileConfigurationItem{#propertyName:'mainDocument',#default:'book'},FileConfigurationItem{#propertyName:'latexTemplate',#default:'_support/templates/main.latex.mustache'},FileConfigurationItem{#propertyName:'latexChapterTemplate',#default:'_support/templates/chapter.latex.mustache'},FileConfigurationItem{#propertyName:'htmlTemplate',#default:'_support/templates/html.mustache'},FileConfigurationItem{#propertyName:'htmlChapterTemplate',#default:'_support/templates/html.mustache'},NewLineConfigurationItem{#propertyName:'newLine',#defaultKey:#unix},SymbolConfigurationItem{#propertyName:'latexWriter',#default:#'latex:sbabook'}]
>
> I see that you pass via a string and me via a stream but I wonder why
> with my solution strings where not escaped.
You're sick that is why you are not thinking clearly ;-)
This has nothing to do with STON, but with Smalltalk syntax.
Say you want to write out a Date creation expression, then the following (what you do) would not work:
Compiler evaluate: (String streamContents: [ :out |
out << 'Date fromString: '.
Date today printOn: out ]).
But the following does (as I did):
Compiler evaluate: (String streamContents: [ :out |
out << 'Date fromString: '.
out print: Date today printString ]).
You need to take the printed representation and turn it into a Smalltalk String literal. If you just put it there, all the characters will be there but the string will not be quoted, nor will embedded quotes be escaped properly.
> Stef
>
> On Tue, Mar 13, 2018 at 5:13 PM, Stephane Ducasse
> <stepharo.self(a)gmail.com> wrote:
>> On Tue, Mar 13, 2018 at 5:12 PM, Stephane Ducasse
>> <stepharo.self(a)gmail.com> wrote:
>>> Tx sven got caught by a flu... freezing in my bed.
>>> I will check.
>>>
>>> On Mon, Mar 12, 2018 at 11:01 PM, Sven Van Caekenberghe <sven(a)stfx.eu> wrote:
>>>> So I guess that you want a Smalltalk expression that, when evaluated, returns an arbitrary STON-ified object as a real object.
>>>>
>>>> Let's say you want to STON-ify the following object:
>>>>
>>>> { #firstName->'Stéphane'. #lastName->'Ducasse'. #note->'Look: '', that was a single quote.' } asDictionary.
>>>>
>>>> Note there is a single quote character inside the #note.
>>>>
>>>> You can do that using #print: when needed. Here is an expression to see how that works:
>>>>
>>>> Compiler evaluate: (String streamContents: [ :out |
>>>> out
>>>> nextPutAll: 'STON fromString: ';
>>>> print: (STON toString: ({ #firstName->'Stéphane'. #lastName->'Ducasse'. #note->'Look: '', that was a single quote.' } asDictionary)) ]).
>>>>
>>>> The Smalltalk expression then looks like this:
>>>>
>>>> STON fromString: '{#note:''Look: \'', that was a single quote.'',#firstName:''Stéphane'',#lastName:''Ducasse''}'
>>>>
>>>> The double single quotes are Smalltalk's syntax's escaping, while the backslashes are STON's. Yes, that is a bit confusing, but consistent.
>>>>
>>>> Is this what you need ?
>>>>
>>>>> On 12 Mar 2018, at 22:43, Stephane Ducasse <stepharo.self(a)gmail.com> wrote:
>>>>>
>>>>> Hi
>>>>>
>>>>> I want to write a method that generate a method that when I execute
>>>>> this recreates the objects that I STONified.
>>>>> (I love STON).
>>>>>
>>>>> So I did something like that
>>>>>
>>>>> descriptionMethodFrom: descriptionItems
>>>>> "self new descriptionMethodFrom: ChrysalConfigurationDescription
>>>>> itemDescriptionForXX"
>>>>>
>>>>> ^ String streamContents: [ :s |
>>>>> s nextPutAll: 'descriptions'; cr.
>>>>> s nextPutAll: '^ STON fromString: '.
>>>>> s nextPutAll: (STON toStringPretty: descriptionItems) ]
>>>>>
>>>>> and I get of course something wrong :) because the strings are not
>>>>> doubel quoted and the first expression is not surrounded by single
>>>>> quote.
>>>>>
>>>>> And I could do it but I want a smart way to do it. I was thinking that
>>>>> may be I'm missing something obvious.
>>>>>
>>>>> descriptions
>>>>> ^ STON fromString: [
>>>>> StringConfigurationItem {
>>>>> #propertyName : 'title',
>>>>> #default : 'my super cool book'
>>>>> },
>>>>> BooleanConfigurationItem {
>>>>> #propertyName : 'verbose',
>>>>> #default : 'true'
>>>>> },
>>>>> StringConfigurationItem {
>>>>> #propertyName : 'attribution',
>>>>> #default : 'me, myself and I'
>>>>> },
>>>>> StringConfigurationItem {
>>>>> #propertyName : 'series',
>>>>> #default : 'Square Bracket Associate Collection'
>>>>> }
>>>>> ]
>>>>>
>>>>
>>>>
>
March 13, 2018
Re: [Pharo-users] About handling strings in streams with STON
by Stephane Ducasse
I originally did
addDescriptionMethodBodyIn: aStream forItems: descriptionItems
aStream nextPutAll: 'STON fromString: '.
STON put: descriptionItems onStream: aStream
and I get
STON fromString:
[StringConfigurationItem{#propertyName:'title',#default:'my super cool
book'},BooleanConfigurationItem{#propertyName:'verbose',#default:'true'},StringConfigurationItem{#propertyName:'attribution',#default:'me,
myself and I'},StringConfigurationItem{#propertyName:'series',#default:'Square
Bracket Associate
Collection'},StringConfigurationItem{#propertyName:'keywords',#default:'Pharo'},FolderConfigurationItem{#propertyName:'outputDirectory',#default:'build'},FileConfigurationItem{#propertyName:'mainDocument',#default:'book'},FileConfigurationItem{#propertyName:'latexTemplate',#default:'_support/templates/main.latex.mustache'},FileConfigurationItem{#propertyName:'latexChapterTemplate',#default:'_support/templates/chapter.latex.mustache'},FileConfigurationItem{#propertyName:'htmlTemplate',#default:'_support/templates/html.mustache'},FileConfigurationItem{#propertyName:'htmlChapterTemplate',#default:'_support/templates/html.mustache'},NewLineConfigurationItem{#propertyName:'newLine',#defaultKey:#unix},SymbolConfigurationItem{#propertyName:'latexWriter',#default:#'latex:sbabook'}]
I see that you pass via a string and me via a stream but I wonder why
with my solution strings where not escaped.
Stef
On Tue, Mar 13, 2018 at 5:13 PM, Stephane Ducasse
<stepharo.self(a)gmail.com> wrote:
> On Tue, Mar 13, 2018 at 5:12 PM, Stephane Ducasse
> <stepharo.self(a)gmail.com> wrote:
>> Tx sven got caught by a flu... freezing in my bed.
>> I will check.
>>
>> On Mon, Mar 12, 2018 at 11:01 PM, Sven Van Caekenberghe <sven(a)stfx.eu> wrote:
>>> So I guess that you want a Smalltalk expression that, when evaluated, returns an arbitrary STON-ified object as a real object.
>>>
>>> Let's say you want to STON-ify the following object:
>>>
>>> { #firstName->'Stéphane'. #lastName->'Ducasse'. #note->'Look: '', that was a single quote.' } asDictionary.
>>>
>>> Note there is a single quote character inside the #note.
>>>
>>> You can do that using #print: when needed. Here is an expression to see how that works:
>>>
>>> Compiler evaluate: (String streamContents: [ :out |
>>> out
>>> nextPutAll: 'STON fromString: ';
>>> print: (STON toString: ({ #firstName->'Stéphane'. #lastName->'Ducasse'. #note->'Look: '', that was a single quote.' } asDictionary)) ]).
>>>
>>> The Smalltalk expression then looks like this:
>>>
>>> STON fromString: '{#note:''Look: \'', that was a single quote.'',#firstName:''Stéphane'',#lastName:''Ducasse''}'
>>>
>>> The double single quotes are Smalltalk's syntax's escaping, while the backslashes are STON's. Yes, that is a bit confusing, but consistent.
>>>
>>> Is this what you need ?
>>>
>>>> On 12 Mar 2018, at 22:43, Stephane Ducasse <stepharo.self(a)gmail.com> wrote:
>>>>
>>>> Hi
>>>>
>>>> I want to write a method that generate a method that when I execute
>>>> this recreates the objects that I STONified.
>>>> (I love STON).
>>>>
>>>> So I did something like that
>>>>
>>>> descriptionMethodFrom: descriptionItems
>>>> "self new descriptionMethodFrom: ChrysalConfigurationDescription
>>>> itemDescriptionForXX"
>>>>
>>>> ^ String streamContents: [ :s |
>>>> s nextPutAll: 'descriptions'; cr.
>>>> s nextPutAll: '^ STON fromString: '.
>>>> s nextPutAll: (STON toStringPretty: descriptionItems) ]
>>>>
>>>> and I get of course something wrong :) because the strings are not
>>>> doubel quoted and the first expression is not surrounded by single
>>>> quote.
>>>>
>>>> And I could do it but I want a smart way to do it. I was thinking that
>>>> may be I'm missing something obvious.
>>>>
>>>> descriptions
>>>> ^ STON fromString: [
>>>> StringConfigurationItem {
>>>> #propertyName : 'title',
>>>> #default : 'my super cool book'
>>>> },
>>>> BooleanConfigurationItem {
>>>> #propertyName : 'verbose',
>>>> #default : 'true'
>>>> },
>>>> StringConfigurationItem {
>>>> #propertyName : 'attribution',
>>>> #default : 'me, myself and I'
>>>> },
>>>> StringConfigurationItem {
>>>> #propertyName : 'series',
>>>> #default : 'Square Bracket Associate Collection'
>>>> }
>>>> ]
>>>>
>>>
>>>
March 13, 2018