Comments in STON

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
23 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Comments in STON

Guillermo Polito
Hi Sven, list,

I'm using Pillar, and thus STON for its configuration file. And since I want users to change configuration files as they want, I wanted to add some comments explaining the meaning of the file fields.

This raises the question: How can I write comments in a ston file? I was checking the STON reader and it looks like that is not supported.

What should be a good comment format?

{
/* The site id is.... */
% comment line
## comment line
-- comment line
"siteid" : ""
}

Guille
Reply | Threaded
Open this post in threaded view
|

Re: Comments in STON

Sven Van Caekenberghe-2
I am not so sure we should add that.

The JSON spec explicitly does not allow comments because of fear of abuse (that the comments would be used to add semantic meaning outside the spec).

I have to think about that.

In any case, I think comments with open/close are generally more useful.

> On 08 Jun 2015, at 16:12, Guillermo Polito <[hidden email]> wrote:
>
> Hi Sven, list,
>
> I'm using Pillar, and thus STON for its configuration file. And since I want users to change configuration files as they want, I wanted to add some comments explaining the meaning of the file fields.
>
> This raises the question: How can I write comments in a ston file? I was checking the STON reader and it looks like that is not supported.
>
> What should be a good comment format?
>
> {
> /* The site id is.... */
> % comment line
> ## comment line
> -- comment line
> "siteid" : ""
> }
>
> Guille


Reply | Threaded
Open this post in threaded view
|

Re: Comments in STON

Damien Cassou-2

Sven Van Caekenberghe <[hidden email]> writes:

> I am not so sure we should add that.
>
> The JSON spec explicitly does not allow comments because of fear of abuse (that the comments would be used to add semantic meaning outside the spec).


really? That's surprising. Comments in configuration files are very
important. Even more when the configuration files are templates for new
users.

--
Damien Cassou
http://damiencassou.seasidehosting.st

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill

Reply | Threaded
Open this post in threaded view
|

Re: Comments in STON

demarey

Le 8 juin 2015 à 17:03, Damien Cassou a écrit :

>
> Sven Van Caekenberghe <[hidden email]> writes:
>
>> I am not so sure we should add that.
>>
>> The JSON spec explicitly does not allow comments because of fear of abuse (that the comments would be used to add semantic meaning outside the spec).
>
>
> really? That's surprising. Comments in configuration files are very
> important. Even more when the configuration files are templates for new
> users.
+1 but it may outline that json/ston is not well suited to configuration files

smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Comments in STON

Sven Van Caekenberghe-2
In reply to this post by Damien Cassou-2

> On 08 Jun 2015, at 17:03, Damien Cassou <[hidden email]> wrote:
>
>
> Sven Van Caekenberghe <[hidden email]> writes:
>
>> I am not so sure we should add that.
>>
>> The JSON spec explicitly does not allow comments because of fear of abuse (that the comments would be used to add semantic meaning outside the spec).
>
>
> really? That's surprising. Comments in configuration files are very
> important. Even more when the configuration files are templates for new
> users.

I know some people are using STON in ways that I did not originally anticipate, that is of course cool, but writing configuration files was not the original goal. STON is a version of JSON that is closer to our object model.

Like I said, I will think about it.

> --
> Damien Cassou
> http://damiencassou.seasidehosting.st
>
> "Success is the ability to go from one failure to another without
> losing enthusiasm." --Winston Churchill
>


Reply | Threaded
Open this post in threaded view
|

Re: Comments in STON

Guillermo Polito
If not we could maybe write a yaml parser :)


It has no brackets, it is also hierarchical and it supports comments.

El lun., 8 de jun. de 2015 a la(s) 5:16 p. m., Sven Van Caekenberghe <[hidden email]> escribió:

> On 08 Jun 2015, at 17:03, Damien Cassou <[hidden email]> wrote:
>
>
> Sven Van Caekenberghe <[hidden email]> writes:
>
>> I am not so sure we should add that.
>>
>> The JSON spec explicitly does not allow comments because of fear of abuse (that the comments would be used to add semantic meaning outside the spec).
>
>
> really? That's surprising. Comments in configuration files are very
> important. Even more when the configuration files are templates for new
> users.

I know some people are using STON in ways that I did not originally anticipate, that is of course cool, but writing configuration files was not the original goal. STON is a version of JSON that is closer to our object model.

Like I said, I will think about it.

> --
> Damien Cassou
> http://damiencassou.seasidehosting.st
>
> "Success is the ability to go from one failure to another without
> losing enthusiasm." --Winston Churchill
>


Reply | Threaded
Open this post in threaded view
|

Re: Comments in STON

Richard Sargent
Administrator
In reply to this post by Damien Cassou-2
Damien Cassou-2 wrote
Sven Van Caekenberghe <[hidden email]> writes:

> I am not so sure we should add that.
>
> The JSON spec explicitly does not allow comments because of fear of abuse (that the comments would be used to add semantic meaning outside the spec).


really? That's surprising. Comments in configuration files are very
important. Even more when the configuration files are templates for new
users.
I think you may have combined two requirements and come up with a "I can adapt this existing idea to handle both" solution. In my experience, I would suggest the word "adapt" in that phrase usually ends up being better read as "pervert".

So, let's step back for a moment and start by clearly and precisely identifying the actual requirements. As I interpret the foregoing discussion, there are two.
1) We want the ability to include information in a configuration which can be used to document, explain, guide those who come after.
2) We want to provide a template configuration that will make it easier for people to figure out how to create a good configuration.

I will also remind everyone of one thing that seems to be a fundamentally important aspect of Smalltalk programming: we prefer code over comments. For example, I came across some unit tests which included comments like "The result should be blah". Generally, we would write that as "self assert: result equals: blah". So, let's add this requirement:
3) The best implementation of a "spec" like a configuration will maximize the DSL capability of Smalltalk.


In my opinion, none of these requirements are well satisfied by adding comments to the STON syntax.

The first requirement, again in my opinion, is best handled by modelling a narrative aspect in configurations. I'm not suggestion how that should be done nor what to call it.

The second requirement seems best satisfied by providing a template configuration file with the its various aspects specified by some example content that clearly illustrates the right way to do it.

And the third requirement is satisfied when the modelling of the configuration formalizes what it is we want it to convey.


--
Damien Cassou
http://damiencassou.seasidehosting.st

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill
Reply | Threaded
Open this post in threaded view
|

Re: Comments in STON

Sven Van Caekenberghe-2
In reply to this post by Sven Van Caekenberghe-2
I would do it like this: use a wrapping stream to skip comments.

===
Name: STON-Core-SvenVanCaekenberghe.59
Author: SvenVanCaekenberghe
Time: 8 June 2015, 11:34:32.886167 pm
UUID: 7ab942b5-9d1a-44c3-9d58-da29feb72380
Ancestors: STON-Core-SvenVanCaekenberghe.58

Add experimental STONCStyleCommentsSkipStream and tests
===
Name: STON-Tests-SvenVanCaekenberghe.54
Author: SvenVanCaekenberghe
Time: 8 June 2015, 11:34:52.918771 pm
UUID: 3dcb2c9c-6efe-4d62-bf36-3bbe91f09d08
Ancestors: STON-Tests-SvenVanCaekenberghe.53

Add experimental STONCStyleCommentsSkipStream and tests
===

Then you can do as follows:

STON fromStream: (STONCStyleCommentsSkipStream on: 'Point[/* this is X*/ 1, /* this is Y*/ 2] // Nice huh ?' readStream).

        => 1@2

STON fromStream: (STONCStyleCommentsSkipStream on: '// Here is how you create a point:
Point[
        // this is X
        1,
        // this is Y
        2 ]
// Nice huh ?' readStream).

        => 1@2

This helper class would be useable in other contexts too (like NeoJSON).

The advantage is that it does not change the STON (or JSON) syntax itself, it just add some functionality for those who want it.

What do you think ?

Sven

PS: this probably needs some more testing

> On 08 Jun 2015, at 17:16, Sven Van Caekenberghe <[hidden email]> wrote:
>
>>
>> On 08 Jun 2015, at 17:03, Damien Cassou <[hidden email]> wrote:
>>
>>
>> Sven Van Caekenberghe <[hidden email]> writes:
>>
>>> I am not so sure we should add that.
>>>
>>> The JSON spec explicitly does not allow comments because of fear of abuse (that the comments would be used to add semantic meaning outside the spec).
>>
>>
>> really? That's surprising. Comments in configuration files are very
>> important. Even more when the configuration files are templates for new
>> users.
>
> I know some people are using STON in ways that I did not originally anticipate, that is of course cool, but writing configuration files was not the original goal. STON is a version of JSON that is closer to our object model.
>
> Like I said, I will think about it.
>
>> --
>> Damien Cassou
>> http://damiencassou.seasidehosting.st
>>
>> "Success is the ability to go from one failure to another without
>> losing enthusiasm." --Winston Churchill


Reply | Threaded
Open this post in threaded view
|

Re: Comments in STON

Damien Cassou-2

Sven Van Caekenberghe <[hidden email]> writes:

> What do you think ?

this looks like a very good solution.

Thank you very much Sven

--
Damien Cassou
http://damiencassou.seasidehosting.st

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill

Reply | Threaded
Open this post in threaded view
|

Re: Comments in STON

Sven Van Caekenberghe-2
You are up very early ;-)

In #bleedingEdge (to be integrated in Pharo 5 later on):

===
Name: STON-Core-SvenVanCaekenberghe.60
Author: SvenVanCaekenberghe
Time: 9 June 2015, 11:04:57.955405 am
UUID: 7b95fcbe-1a44-4c94-a196-042e4cdb3e97
Ancestors: STON-Core-SvenVanCaekenberghe.59

Add 2 convenience methods:

        STON class>>#fromStringWithComments:
        STON class>>#fromStreamWithComments:
       
Add more unit tests for the new functionality
===
Name: STON-Tests-SvenVanCaekenberghe.55
Author: SvenVanCaekenberghe
Time: 9 June 2015, 11:05:12.121701 am
UUID: 14ccb834-8db6-4577-aeb9-1bdd487c3ab8
Ancestors: STON-Tests-SvenVanCaekenberghe.54

Add 2 convenience methods:

        STON class>>#fromStringWithComments:
        STON class>>#fromStreamWithComments:
       
Add more unit tests for the new functionality
===

So now you can write:

STON fromStringWithComments: 'Point[/* this is X*/ 1, /* this is Y*/ 2] // Nice huh ?'.

STON fromStringWithComments: '// Here is how you create a point:
Point[
        // this is X
        1,
        // this is Y
        2 ]
// Nice huh ?'.

The point of Richard is quite relevant though. Right now, the comments are literally filtered out and thrown away. Maybe you do not want that, and maybe you want to model the comments explicitly. A bit like:

MyGreatAppConfig {
  #comment : 'This is a comment',
  #hostname : 'localhost',
  #port : 8080,
  #datasources : [
    MyDataConfig {
      #comment : 'First datasource',
      #url: 'postgresql://blabla' },
    MyDataConfig {
      #comment : 'Second datasource',
      #url: 'postgresql://blabla' }
  ]
}

This way, when you write out the config, the comments remain in place. Of course, the disadvantage is that people can only put comments in places where this is explicitly allowed.

Sven

> On 09 Jun 2015, at 05:33, Damien Cassou <[hidden email]> wrote:
>
>
> Sven Van Caekenberghe <[hidden email]> writes:
>
>> What do you think ?
>
> this looks like a very good solution.
>
> Thank you very much Sven
>
> --
> Damien Cassou
> http://damiencassou.seasidehosting.st
>
> "Success is the ability to go from one failure to another without
> losing enthusiasm." --Winston Churchill
>


Reply | Threaded
Open this post in threaded view
|

Re: Comments in STON

Guillermo Polito
Cool!

Actually I just wanted comments as a way of self documentation. So ignoring comments is more than enough for what I wanted :)

Thanks!

El mar., 9 de jun. de 2015 a la(s) 11:16 a. m., Sven Van Caekenberghe <[hidden email]> escribió:
You are up very early ;-)

In #bleedingEdge (to be integrated in Pharo 5 later on):

===
Name: STON-Core-SvenVanCaekenberghe.60
Author: SvenVanCaekenberghe
Time: 9 June 2015, 11:04:57.955405 am
UUID: 7b95fcbe-1a44-4c94-a196-042e4cdb3e97
Ancestors: STON-Core-SvenVanCaekenberghe.59

Add 2 convenience methods:

        STON class>>#fromStringWithComments:
        STON class>>#fromStreamWithComments:

Add more unit tests for the new functionality
===
Name: STON-Tests-SvenVanCaekenberghe.55
Author: SvenVanCaekenberghe
Time: 9 June 2015, 11:05:12.121701 am
UUID: 14ccb834-8db6-4577-aeb9-1bdd487c3ab8
Ancestors: STON-Tests-SvenVanCaekenberghe.54

Add 2 convenience methods:

        STON class>>#fromStringWithComments:
        STON class>>#fromStreamWithComments:

Add more unit tests for the new functionality
===

So now you can write:

STON fromStringWithComments: 'Point[/* this is X*/ 1, /* this is Y*/ 2] // Nice huh ?'.

STON fromStringWithComments: '// Here is how you create a point:
Point[
        // this is X
        1,
        // this is Y
        2 ]
// Nice huh ?'.

The point of Richard is quite relevant though. Right now, the comments are literally filtered out and thrown away. Maybe you do not want that, and maybe you want to model the comments explicitly. A bit like:

MyGreatAppConfig {
  #comment : 'This is a comment',
  #hostname : 'localhost',
  #port : 8080,
  #datasources : [
    MyDataConfig {
      #comment : 'First datasource',
      #url: 'postgresql://blabla' },
    MyDataConfig {
      #comment : 'Second datasource',
      #url: 'postgresql://blabla' }
  ]
}

This way, when you write out the config, the comments remain in place. Of course, the disadvantage is that people can only put comments in places where this is explicitly allowed.

Sven

> On 09 Jun 2015, at 05:33, Damien Cassou <[hidden email]> wrote:
>
>
> Sven Van Caekenberghe <[hidden email]> writes:
>
>> What do you think ?
>
> this looks like a very good solution.
>
> Thank you very much Sven
>
> --
> Damien Cassou
> http://damiencassou.seasidehosting.st
>
> "Success is the ability to go from one failure to another without
> losing enthusiasm." --Winston Churchill
>


Reply | Threaded
Open this post in threaded view
|

Re: Comments in STON

stepharo
In reply to this post by Guillermo Polito
so ugly!



Le 8/6/15 17:27, Guillermo Polito a écrit :
If not we could maybe write a yaml parser :)


It has no brackets, it is also hierarchical and it supports comments.

El lun., 8 de jun. de 2015 a la(s) 5:16 p. m., Sven Van Caekenberghe <[hidden email]> escribió:

> On 08 Jun 2015, at 17:03, Damien Cassou <[hidden email]> wrote:
>
>
> Sven Van Caekenberghe <[hidden email]> writes:
>
>> I am not so sure we should add that.
>>
>> The JSON spec explicitly does not allow comments because of fear of abuse (that the comments would be used to add semantic meaning outside the spec).
>
>
> really? That's surprising. Comments in configuration files are very
> important. Even more when the configuration files are templates for new
> users.

I know some people are using STON in ways that I did not originally anticipate, that is of course cool, but writing configuration files was not the original goal. STON is a version of JSON that is closer to our object model.

Like I said, I will think about it.

> --
> Damien Cassou
> http://damiencassou.seasidehosting.st
>
> "Success is the ability to go from one failure to another without
> losing enthusiasm." --Winston Churchill
>



Reply | Threaded
Open this post in threaded view
|

Re: Comments in STON

stepharo
In reply to this post by Sven Van Caekenberghe-2
I will update the STON chapter :)


Le 8/6/15 23:39, Sven Van Caekenberghe a écrit :

> I would do it like this: use a wrapping stream to skip comments.
>
> ===
> Name: STON-Core-SvenVanCaekenberghe.59
> Author: SvenVanCaekenberghe
> Time: 8 June 2015, 11:34:32.886167 pm
> UUID: 7ab942b5-9d1a-44c3-9d58-da29feb72380
> Ancestors: STON-Core-SvenVanCaekenberghe.58
>
> Add experimental STONCStyleCommentsSkipStream and tests
> ===
> Name: STON-Tests-SvenVanCaekenberghe.54
> Author: SvenVanCaekenberghe
> Time: 8 June 2015, 11:34:52.918771 pm
> UUID: 3dcb2c9c-6efe-4d62-bf36-3bbe91f09d08
> Ancestors: STON-Tests-SvenVanCaekenberghe.53
>
> Add experimental STONCStyleCommentsSkipStream and tests
> ===
>
> Then you can do as follows:
>
> STON fromStream: (STONCStyleCommentsSkipStream on: 'Point[/* this is X*/ 1, /* this is Y*/ 2] // Nice huh ?' readStream).
>
> => 1@2
>
> STON fromStream: (STONCStyleCommentsSkipStream on: '// Here is how you create a point:
> Point[
> // this is X
> 1,
> // this is Y
> 2 ]
> // Nice huh ?' readStream).
>
> => 1@2
>
> This helper class would be useable in other contexts too (like NeoJSON).
>
> The advantage is that it does not change the STON (or JSON) syntax itself, it just add some functionality for those who want it.
>
> What do you think ?
>
> Sven
>
> PS: this probably needs some more testing
>
>> On 08 Jun 2015, at 17:16, Sven Van Caekenberghe <[hidden email]> wrote:
>>
>>> On 08 Jun 2015, at 17:03, Damien Cassou <[hidden email]> wrote:
>>>
>>>
>>> Sven Van Caekenberghe <[hidden email]> writes:
>>>
>>>> I am not so sure we should add that.
>>>>
>>>> The JSON spec explicitly does not allow comments because of fear of abuse (that the comments would be used to add semantic meaning outside the spec).
>>>
>>> really? That's surprising. Comments in configuration files are very
>>> important. Even more when the configuration files are templates for new
>>> users.
>> I know some people are using STON in ways that I did not originally anticipate, that is of course cool, but writing configuration files was not the original goal. STON is a version of JSON that is closer to our object model.
>>
>> Like I said, I will think about it.
>>
>>> --
>>> Damien Cassou
>>> http://damiencassou.seasidehosting.st
>>>
>>> "Success is the ability to go from one failure to another without
>>> losing enthusiasm." --Winston Churchill
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Comments in STON

stepharo


Le 9/6/15 20:06, stepharo a écrit :
> I will update the STON chapter :)

Done :)

>
>
> Le 8/6/15 23:39, Sven Van Caekenberghe a écrit :
>> I would do it like this: use a wrapping stream to skip comments.
>>
>> ===
>> Name: STON-Core-SvenVanCaekenberghe.59
>> Author: SvenVanCaekenberghe
>> Time: 8 June 2015, 11:34:32.886167 pm
>> UUID: 7ab942b5-9d1a-44c3-9d58-da29feb72380
>> Ancestors: STON-Core-SvenVanCaekenberghe.58
>>
>> Add experimental STONCStyleCommentsSkipStream and tests
>> ===
>> Name: STON-Tests-SvenVanCaekenberghe.54
>> Author: SvenVanCaekenberghe
>> Time: 8 June 2015, 11:34:52.918771 pm
>> UUID: 3dcb2c9c-6efe-4d62-bf36-3bbe91f09d08
>> Ancestors: STON-Tests-SvenVanCaekenberghe.53
>>
>> Add experimental STONCStyleCommentsSkipStream and tests
>> ===
>>
>> Then you can do as follows:
>>
>> STON fromStream: (STONCStyleCommentsSkipStream on: 'Point[/* this is
>> X*/ 1, /* this is Y*/ 2] // Nice huh ?' readStream).
>>
>>     => 1@2
>>
>> STON fromStream: (STONCStyleCommentsSkipStream on: '// Here is how
>> you create a point:
>> Point[
>>     // this is X
>>     1,
>>     // this is Y
>>     2 ]
>> // Nice huh ?' readStream).
>>
>>     => 1@2
>>
>> This helper class would be useable in other contexts too (like NeoJSON).
>>
>> The advantage is that it does not change the STON (or JSON) syntax
>> itself, it just add some functionality for those who want it.
>>
>> What do you think ?
>>
>> Sven
>>
>> PS: this probably needs some more testing
>>
>>> On 08 Jun 2015, at 17:16, Sven Van Caekenberghe <[hidden email]> wrote:
>>>
>>>> On 08 Jun 2015, at 17:03, Damien Cassou <[hidden email]>
>>>> wrote:
>>>>
>>>>
>>>> Sven Van Caekenberghe <[hidden email]> writes:
>>>>
>>>>> I am not so sure we should add that.
>>>>>
>>>>> The JSON spec explicitly does not allow comments because of fear
>>>>> of abuse (that the comments would be used to add semantic meaning
>>>>> outside the spec).
>>>>
>>>> really? That's surprising. Comments in configuration files are very
>>>> important. Even more when the configuration files are templates for
>>>> new
>>>> users.
>>> I know some people are using STON in ways that I did not originally
>>> anticipate, that is of course cool, but writing configuration files
>>> was not the original goal. STON is a version of JSON that is closer
>>> to our object model.
>>>
>>> Like I said, I will think about it.
>>>
>>>> --
>>>> Damien Cassou
>>>> http://damiencassou.seasidehosting.st
>>>>
>>>> "Success is the ability to go from one failure to another without
>>>> losing enthusiasm." --Winston Churchill
>>
>>
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Comments in STON

Sven Van Caekenberghe-2
Where exactly can I find what you changed ?
I don't see any commit of you on github ...

> On 09 Jun 2015, at 20:10, stepharo <[hidden email]> wrote:
>
>
>
> Le 9/6/15 20:06, stepharo a écrit :
>> I will update the STON chapter :)
>
> Done :)
>
>>
>>
>> Le 8/6/15 23:39, Sven Van Caekenberghe a écrit :
>>> I would do it like this: use a wrapping stream to skip comments.
>>>
>>> ===
>>> Name: STON-Core-SvenVanCaekenberghe.59
>>> Author: SvenVanCaekenberghe
>>> Time: 8 June 2015, 11:34:32.886167 pm
>>> UUID: 7ab942b5-9d1a-44c3-9d58-da29feb72380
>>> Ancestors: STON-Core-SvenVanCaekenberghe.58
>>>
>>> Add experimental STONCStyleCommentsSkipStream and tests
>>> ===
>>> Name: STON-Tests-SvenVanCaekenberghe.54
>>> Author: SvenVanCaekenberghe
>>> Time: 8 June 2015, 11:34:52.918771 pm
>>> UUID: 3dcb2c9c-6efe-4d62-bf36-3bbe91f09d08
>>> Ancestors: STON-Tests-SvenVanCaekenberghe.53
>>>
>>> Add experimental STONCStyleCommentsSkipStream and tests
>>> ===
>>>
>>> Then you can do as follows:
>>>
>>> STON fromStream: (STONCStyleCommentsSkipStream on: 'Point[/* this is X*/ 1, /* this is Y*/ 2] // Nice huh ?' readStream).
>>>
>>>    => 1@2
>>>
>>> STON fromStream: (STONCStyleCommentsSkipStream on: '// Here is how you create a point:
>>> Point[
>>>    // this is X
>>>    1,
>>>    // this is Y
>>>    2 ]
>>> // Nice huh ?' readStream).
>>>
>>>    => 1@2
>>>
>>> This helper class would be useable in other contexts too (like NeoJSON).
>>>
>>> The advantage is that it does not change the STON (or JSON) syntax itself, it just add some functionality for those who want it.
>>>
>>> What do you think ?
>>>
>>> Sven
>>>
>>> PS: this probably needs some more testing
>>>
>>>> On 08 Jun 2015, at 17:16, Sven Van Caekenberghe <[hidden email]> wrote:
>>>>
>>>>> On 08 Jun 2015, at 17:03, Damien Cassou <[hidden email]> wrote:
>>>>>
>>>>>
>>>>> Sven Van Caekenberghe <[hidden email]> writes:
>>>>>
>>>>>> I am not so sure we should add that.
>>>>>>
>>>>>> The JSON spec explicitly does not allow comments because of fear of abuse (that the comments would be used to add semantic meaning outside the spec).
>>>>>
>>>>> really? That's surprising. Comments in configuration files are very
>>>>> important. Even more when the configuration files are templates for new
>>>>> users.
>>>> I know some people are using STON in ways that I did not originally anticipate, that is of course cool, but writing configuration files was not the original goal. STON is a version of JSON that is closer to our object model.
>>>>
>>>> Like I said, I will think about it.
>>>>
>>>>> --
>>>>> Damien Cassou
>>>>> http://damiencassou.seasidehosting.st
>>>>>
>>>>> "Success is the ability to go from one failure to another without
>>>>> losing enthusiasm." --Winston Churchill
>>>
>>>
>>
>>
>>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Comments in STON

stepharo
This is in the entreprise book. I added a subsection on comments.
May be I committed but forgot to push.
Now I did it.

Stef


Le 9/6/15 21:50, Sven Van Caekenberghe a écrit :

> Where exactly can I find what you changed ?
> I don't see any commit of you on github ...
>
>> On 09 Jun 2015, at 20:10, stepharo <[hidden email]> wrote:
>>
>>
>>
>> Le 9/6/15 20:06, stepharo a écrit :
>>> I will update the STON chapter :)
>> Done :)
>>
>>>
>>> Le 8/6/15 23:39, Sven Van Caekenberghe a écrit :
>>>> I would do it like this: use a wrapping stream to skip comments.
>>>>
>>>> ===
>>>> Name: STON-Core-SvenVanCaekenberghe.59
>>>> Author: SvenVanCaekenberghe
>>>> Time: 8 June 2015, 11:34:32.886167 pm
>>>> UUID: 7ab942b5-9d1a-44c3-9d58-da29feb72380
>>>> Ancestors: STON-Core-SvenVanCaekenberghe.58
>>>>
>>>> Add experimental STONCStyleCommentsSkipStream and tests
>>>> ===
>>>> Name: STON-Tests-SvenVanCaekenberghe.54
>>>> Author: SvenVanCaekenberghe
>>>> Time: 8 June 2015, 11:34:52.918771 pm
>>>> UUID: 3dcb2c9c-6efe-4d62-bf36-3bbe91f09d08
>>>> Ancestors: STON-Tests-SvenVanCaekenberghe.53
>>>>
>>>> Add experimental STONCStyleCommentsSkipStream and tests
>>>> ===
>>>>
>>>> Then you can do as follows:
>>>>
>>>> STON fromStream: (STONCStyleCommentsSkipStream on: 'Point[/* this is X*/ 1, /* this is Y*/ 2] // Nice huh ?' readStream).
>>>>
>>>>     => 1@2
>>>>
>>>> STON fromStream: (STONCStyleCommentsSkipStream on: '// Here is how you create a point:
>>>> Point[
>>>>     // this is X
>>>>     1,
>>>>     // this is Y
>>>>     2 ]
>>>> // Nice huh ?' readStream).
>>>>
>>>>     => 1@2
>>>>
>>>> This helper class would be useable in other contexts too (like NeoJSON).
>>>>
>>>> The advantage is that it does not change the STON (or JSON) syntax itself, it just add some functionality for those who want it.
>>>>
>>>> What do you think ?
>>>>
>>>> Sven
>>>>
>>>> PS: this probably needs some more testing
>>>>
>>>>> On 08 Jun 2015, at 17:16, Sven Van Caekenberghe <[hidden email]> wrote:
>>>>>
>>>>>> On 08 Jun 2015, at 17:03, Damien Cassou <[hidden email]> wrote:
>>>>>>
>>>>>>
>>>>>> Sven Van Caekenberghe <[hidden email]> writes:
>>>>>>
>>>>>>> I am not so sure we should add that.
>>>>>>>
>>>>>>> The JSON spec explicitly does not allow comments because of fear of abuse (that the comments would be used to add semantic meaning outside the spec).
>>>>>> really? That's surprising. Comments in configuration files are very
>>>>>> important. Even more when the configuration files are templates for new
>>>>>> users.
>>>>> I know some people are using STON in ways that I did not originally anticipate, that is of course cool, but writing configuration files was not the original goal. STON is a version of JSON that is closer to our object model.
>>>>>
>>>>> Like I said, I will think about it.
>>>>>
>>>>>> --
>>>>>> Damien Cassou
>>>>>> http://damiencassou.seasidehosting.st
>>>>>>
>>>>>> "Success is the ability to go from one failure to another without
>>>>>> losing enthusiasm." --Winston Churchill
>>>>
>>>
>>>
>>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Comments in STON

Sven Van Caekenberghe-2

> On 10 Jun 2015, at 15:13, stepharo <[hidden email]> wrote:
>
> This is in the entreprise book. I added a subsection on comments.
> May be I committed but forgot to push.
> Now I did it.

And now I see it.
I made a small change.

> Stef
>
>
> Le 9/6/15 21:50, Sven Van Caekenberghe a écrit :
>> Where exactly can I find what you changed ?
>> I don't see any commit of you on github ...
>>
>>> On 09 Jun 2015, at 20:10, stepharo <[hidden email]> wrote:
>>>
>>>
>>>
>>> Le 9/6/15 20:06, stepharo a écrit :
>>>> I will update the STON chapter :)
>>> Done :)
>>>
>>>>
>>>> Le 8/6/15 23:39, Sven Van Caekenberghe a écrit :
>>>>> I would do it like this: use a wrapping stream to skip comments.
>>>>>
>>>>> ===
>>>>> Name: STON-Core-SvenVanCaekenberghe.59
>>>>> Author: SvenVanCaekenberghe
>>>>> Time: 8 June 2015, 11:34:32.886167 pm
>>>>> UUID: 7ab942b5-9d1a-44c3-9d58-da29feb72380
>>>>> Ancestors: STON-Core-SvenVanCaekenberghe.58
>>>>>
>>>>> Add experimental STONCStyleCommentsSkipStream and tests
>>>>> ===
>>>>> Name: STON-Tests-SvenVanCaekenberghe.54
>>>>> Author: SvenVanCaekenberghe
>>>>> Time: 8 June 2015, 11:34:52.918771 pm
>>>>> UUID: 3dcb2c9c-6efe-4d62-bf36-3bbe91f09d08
>>>>> Ancestors: STON-Tests-SvenVanCaekenberghe.53
>>>>>
>>>>> Add experimental STONCStyleCommentsSkipStream and tests
>>>>> ===
>>>>>
>>>>> Then you can do as follows:
>>>>>
>>>>> STON fromStream: (STONCStyleCommentsSkipStream on: 'Point[/* this is X*/ 1, /* this is Y*/ 2] // Nice huh ?' readStream).
>>>>>
>>>>>    => 1@2
>>>>>
>>>>> STON fromStream: (STONCStyleCommentsSkipStream on: '// Here is how you create a point:
>>>>> Point[
>>>>>    // this is X
>>>>>    1,
>>>>>    // this is Y
>>>>>    2 ]
>>>>> // Nice huh ?' readStream).
>>>>>
>>>>>    => 1@2
>>>>>
>>>>> This helper class would be useable in other contexts too (like NeoJSON).
>>>>>
>>>>> The advantage is that it does not change the STON (or JSON) syntax itself, it just add some functionality for those who want it.
>>>>>
>>>>> What do you think ?
>>>>>
>>>>> Sven
>>>>>
>>>>> PS: this probably needs some more testing
>>>>>
>>>>>> On 08 Jun 2015, at 17:16, Sven Van Caekenberghe <[hidden email]> wrote:
>>>>>>
>>>>>>> On 08 Jun 2015, at 17:03, Damien Cassou <[hidden email]> wrote:
>>>>>>>
>>>>>>>
>>>>>>> Sven Van Caekenberghe <[hidden email]> writes:
>>>>>>>
>>>>>>>> I am not so sure we should add that.
>>>>>>>>
>>>>>>>> The JSON spec explicitly does not allow comments because of fear of abuse (that the comments would be used to add semantic meaning outside the spec).
>>>>>>> really? That's surprising. Comments in configuration files are very
>>>>>>> important. Even more when the configuration files are templates for new
>>>>>>> users.
>>>>>> I know some people are using STON in ways that I did not originally anticipate, that is of course cool, but writing configuration files was not the original goal. STON is a version of JSON that is closer to our object model.
>>>>>>
>>>>>> Like I said, I will think about it.
>>>>>>
>>>>>>> --
>>>>>>> Damien Cassou
>>>>>>> http://damiencassou.seasidehosting.st
>>>>>>>
>>>>>>> "Success is the ability to go from one failure to another without
>>>>>>> losing enthusiasm." --Winston Churchill
>>>>>
>>>>
>>>>
>>>
>>
>>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Comments in STON

stepharo


Le 10/6/15 20:39, Sven Van Caekenberghe a écrit :
>> On 10 Jun 2015, at 15:13, stepharo <[hidden email]> wrote:
>>
>> This is in the entreprise book. I added a subsection on comments.
>> May be I committed but forgot to push.
>> Now I did it.
> And now I see it.
> I made a small change.
super!

>
>> Stef
>>
>>
>> Le 9/6/15 21:50, Sven Van Caekenberghe a écrit :
>>> Where exactly can I find what you changed ?
>>> I don't see any commit of you on github ...
>>>
>>>> On 09 Jun 2015, at 20:10, stepharo <[hidden email]> wrote:
>>>>
>>>>
>>>>
>>>> Le 9/6/15 20:06, stepharo a écrit :
>>>>> I will update the STON chapter :)
>>>> Done :)
>>>>
>>>>> Le 8/6/15 23:39, Sven Van Caekenberghe a écrit :
>>>>>> I would do it like this: use a wrapping stream to skip comments.
>>>>>>
>>>>>> ===
>>>>>> Name: STON-Core-SvenVanCaekenberghe.59
>>>>>> Author: SvenVanCaekenberghe
>>>>>> Time: 8 June 2015, 11:34:32.886167 pm
>>>>>> UUID: 7ab942b5-9d1a-44c3-9d58-da29feb72380
>>>>>> Ancestors: STON-Core-SvenVanCaekenberghe.58
>>>>>>
>>>>>> Add experimental STONCStyleCommentsSkipStream and tests
>>>>>> ===
>>>>>> Name: STON-Tests-SvenVanCaekenberghe.54
>>>>>> Author: SvenVanCaekenberghe
>>>>>> Time: 8 June 2015, 11:34:52.918771 pm
>>>>>> UUID: 3dcb2c9c-6efe-4d62-bf36-3bbe91f09d08
>>>>>> Ancestors: STON-Tests-SvenVanCaekenberghe.53
>>>>>>
>>>>>> Add experimental STONCStyleCommentsSkipStream and tests
>>>>>> ===
>>>>>>
>>>>>> Then you can do as follows:
>>>>>>
>>>>>> STON fromStream: (STONCStyleCommentsSkipStream on: 'Point[/* this is X*/ 1, /* this is Y*/ 2] // Nice huh ?' readStream).
>>>>>>
>>>>>>     => 1@2
>>>>>>
>>>>>> STON fromStream: (STONCStyleCommentsSkipStream on: '// Here is how you create a point:
>>>>>> Point[
>>>>>>     // this is X
>>>>>>     1,
>>>>>>     // this is Y
>>>>>>     2 ]
>>>>>> // Nice huh ?' readStream).
>>>>>>
>>>>>>     => 1@2
>>>>>>
>>>>>> This helper class would be useable in other contexts too (like NeoJSON).
>>>>>>
>>>>>> The advantage is that it does not change the STON (or JSON) syntax itself, it just add some functionality for those who want it.
>>>>>>
>>>>>> What do you think ?
>>>>>>
>>>>>> Sven
>>>>>>
>>>>>> PS: this probably needs some more testing
>>>>>>
>>>>>>> On 08 Jun 2015, at 17:16, Sven Van Caekenberghe <[hidden email]> wrote:
>>>>>>>
>>>>>>>> On 08 Jun 2015, at 17:03, Damien Cassou <[hidden email]> wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>> Sven Van Caekenberghe <[hidden email]> writes:
>>>>>>>>
>>>>>>>>> I am not so sure we should add that.
>>>>>>>>>
>>>>>>>>> The JSON spec explicitly does not allow comments because of fear of abuse (that the comments would be used to add semantic meaning outside the spec).
>>>>>>>> really? That's surprising. Comments in configuration files are very
>>>>>>>> important. Even more when the configuration files are templates for new
>>>>>>>> users.
>>>>>>> I know some people are using STON in ways that I did not originally anticipate, that is of course cool, but writing configuration files was not the original goal. STON is a version of JSON that is closer to our object model.
>>>>>>>
>>>>>>> Like I said, I will think about it.
>>>>>>>
>>>>>>>> --
>>>>>>>> Damien Cassou
>>>>>>>> http://damiencassou.seasidehosting.st
>>>>>>>>
>>>>>>>> "Success is the ability to go from one failure to another without
>>>>>>>> losing enthusiasm." --Winston Churchill
>>>>>
>>>
>>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Comments in STON

Guillermo Polito
Hi Sven!

I'm finally using the new STON with comments and I found one little problem: my ston file has urls :/

{
// comment ok, skipped
/* comment ok, skipped */
}

That is, doing:

STON fromStreamWithComments: '{
// comment ok, skipped
/* comment ok, skipped */
}' readStream

Will fail with an invalid input error because after skipping comments my STON stream remains like

STON fromStreamWithComments: '{
  "aURL": "http:
}

Any thoughts?
Guille

El dom., 14 de jun. de 2015 a la(s) 3:06 a. m., stepharo <[hidden email]> escribió:


Le 10/6/15 20:39, Sven Van Caekenberghe a écrit :
>> On 10 Jun 2015, at 15:13, stepharo <[hidden email]> wrote:
>>
>> This is in the entreprise book. I added a subsection on comments.
>> May be I committed but forgot to push.
>> Now I did it.
> And now I see it.
> I made a small change.
super!

>
>> Stef
>>
>>
>> Le 9/6/15 21:50, Sven Van Caekenberghe a écrit :
>>> Where exactly can I find what you changed ?
>>> I don't see any commit of you on github ...
>>>
>>>> On 09 Jun 2015, at 20:10, stepharo <[hidden email]> wrote:
>>>>
>>>>
>>>>
>>>> Le 9/6/15 20:06, stepharo a écrit :
>>>>> I will update the STON chapter :)
>>>> Done :)
>>>>
>>>>> Le 8/6/15 23:39, Sven Van Caekenberghe a écrit :
>>>>>> I would do it like this: use a wrapping stream to skip comments.
>>>>>>
>>>>>> ===
>>>>>> Name: STON-Core-SvenVanCaekenberghe.59
>>>>>> Author: SvenVanCaekenberghe
>>>>>> Time: 8 June 2015, 11:34:32.886167 pm
>>>>>> UUID: 7ab942b5-9d1a-44c3-9d58-da29feb72380
>>>>>> Ancestors: STON-Core-SvenVanCaekenberghe.58
>>>>>>
>>>>>> Add experimental STONCStyleCommentsSkipStream and tests
>>>>>> ===
>>>>>> Name: STON-Tests-SvenVanCaekenberghe.54
>>>>>> Author: SvenVanCaekenberghe
>>>>>> Time: 8 June 2015, 11:34:52.918771 pm
>>>>>> UUID: 3dcb2c9c-6efe-4d62-bf36-3bbe91f09d08
>>>>>> Ancestors: STON-Tests-SvenVanCaekenberghe.53
>>>>>>
>>>>>> Add experimental STONCStyleCommentsSkipStream and tests
>>>>>> ===
>>>>>>
>>>>>> Then you can do as follows:
>>>>>>
>>>>>> STON fromStream: (STONCStyleCommentsSkipStream on: 'Point[/* this is X*/ 1, /* this is Y*/ 2] // Nice huh ?' readStream).
>>>>>>
>>>>>>     => 1@2
>>>>>>
>>>>>> STON fromStream: (STONCStyleCommentsSkipStream on: '// Here is how you create a point:
>>>>>> Point[
>>>>>>     // this is X
>>>>>>     1,
>>>>>>     // this is Y
>>>>>>     2 ]
>>>>>> // Nice huh ?' readStream).
>>>>>>
>>>>>>     => 1@2
>>>>>>
>>>>>> This helper class would be useable in other contexts too (like NeoJSON).
>>>>>>
>>>>>> The advantage is that it does not change the STON (or JSON) syntax itself, it just add some functionality for those who want it.
>>>>>>
>>>>>> What do you think ?
>>>>>>
>>>>>> Sven
>>>>>>
>>>>>> PS: this probably needs some more testing
>>>>>>
>>>>>>> On 08 Jun 2015, at 17:16, Sven Van Caekenberghe <[hidden email]> wrote:
>>>>>>>
>>>>>>>> On 08 Jun 2015, at 17:03, Damien Cassou <[hidden email]> wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>> Sven Van Caekenberghe <[hidden email]> writes:
>>>>>>>>
>>>>>>>>> I am not so sure we should add that.
>>>>>>>>>
>>>>>>>>> The JSON spec explicitly does not allow comments because of fear of abuse (that the comments would be used to add semantic meaning outside the spec).
>>>>>>>> really? That's surprising. Comments in configuration files are very
>>>>>>>> important. Even more when the configuration files are templates for new
>>>>>>>> users.
>>>>>>> I know some people are using STON in ways that I did not originally anticipate, that is of course cool, but writing configuration files was not the original goal. STON is a version of JSON that is closer to our object model.
>>>>>>>
>>>>>>> Like I said, I will think about it.
>>>>>>>
>>>>>>>> --
>>>>>>>> Damien Cassou
>>>>>>>> http://damiencassou.seasidehosting.st
>>>>>>>>
>>>>>>>> "Success is the ability to go from one failure to another without
>>>>>>>> losing enthusiasm." --Winston Churchill
>>>>>
>>>
>>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Comments in STON

Sven Van Caekenberghe-2
Guille,

I understand the problem.

The reason is that STONCStyleCommentsSkipStream was/is a quick hack and does not know/understand anything about strings.

It seems that the C preprocessor ignores comments in C strings, so we could consider adding that.

Basically STONCStyleCommentsSkipStream>>#nextNonCommentChar should know when it is inside a string and then ignore comments. But that means, in the case of STON/JSON, handling both ' (single) and " (double) quoted strings as well as interpret \' and \". All this should be doable, but it is not that easy to do elegantly. I'll see what I can do.

Sven

> On 16 Jul 2015, at 17:35, Guillermo Polito <[hidden email]> wrote:
>
> Hi Sven!
>
> I'm finally using the new STON with comments and I found one little problem: my ston file has urls :/
>
> {
> // comment ok, skipped
> /* comment ok, skipped */
>   "aURL": "http://ouch.it.will.be.skipped/and/break?my=ston"
> }
>
> That is, doing:
>
> STON fromStreamWithComments: '{
> // comment ok, skipped
> /* comment ok, skipped */
>   "aURL": "http://ouch.it.will.be.skipped/and/break?my=ston"
> }' readStream
>
> Will fail with an invalid input error because after skipping comments my STON stream remains like
>
> STON fromStreamWithComments: '{
>   "aURL": "http:
> }
>
> Any thoughts?
> Guille
>
> El dom., 14 de jun. de 2015 a la(s) 3:06 a. m., stepharo <[hidden email]> escribió:
>
>
> Le 10/6/15 20:39, Sven Van Caekenberghe a écrit :
> >> On 10 Jun 2015, at 15:13, stepharo <[hidden email]> wrote:
> >>
> >> This is in the entreprise book. I added a subsection on comments.
> >> May be I committed but forgot to push.
> >> Now I did it.
> > And now I see it.
> > I made a small change.
> super!
>
> >
> >> Stef
> >>
> >>
> >> Le 9/6/15 21:50, Sven Van Caekenberghe a écrit :
> >>> Where exactly can I find what you changed ?
> >>> I don't see any commit of you on github ...
> >>>
> >>>> On 09 Jun 2015, at 20:10, stepharo <[hidden email]> wrote:
> >>>>
> >>>>
> >>>>
> >>>> Le 9/6/15 20:06, stepharo a écrit :
> >>>>> I will update the STON chapter :)
> >>>> Done :)
> >>>>
> >>>>> Le 8/6/15 23:39, Sven Van Caekenberghe a écrit :
> >>>>>> I would do it like this: use a wrapping stream to skip comments.
> >>>>>>
> >>>>>> ===
> >>>>>> Name: STON-Core-SvenVanCaekenberghe.59
> >>>>>> Author: SvenVanCaekenberghe
> >>>>>> Time: 8 June 2015, 11:34:32.886167 pm
> >>>>>> UUID: 7ab942b5-9d1a-44c3-9d58-da29feb72380
> >>>>>> Ancestors: STON-Core-SvenVanCaekenberghe.58
> >>>>>>
> >>>>>> Add experimental STONCStyleCommentsSkipStream and tests
> >>>>>> ===
> >>>>>> Name: STON-Tests-SvenVanCaekenberghe.54
> >>>>>> Author: SvenVanCaekenberghe
> >>>>>> Time: 8 June 2015, 11:34:52.918771 pm
> >>>>>> UUID: 3dcb2c9c-6efe-4d62-bf36-3bbe91f09d08
> >>>>>> Ancestors: STON-Tests-SvenVanCaekenberghe.53
> >>>>>>
> >>>>>> Add experimental STONCStyleCommentsSkipStream and tests
> >>>>>> ===
> >>>>>>
> >>>>>> Then you can do as follows:
> >>>>>>
> >>>>>> STON fromStream: (STONCStyleCommentsSkipStream on: 'Point[/* this is X*/ 1, /* this is Y*/ 2] // Nice huh ?' readStream).
> >>>>>>
> >>>>>>     => 1@2
> >>>>>>
> >>>>>> STON fromStream: (STONCStyleCommentsSkipStream on: '// Here is how you create a point:
> >>>>>> Point[
> >>>>>>     // this is X
> >>>>>>     1,
> >>>>>>     // this is Y
> >>>>>>     2 ]
> >>>>>> // Nice huh ?' readStream).
> >>>>>>
> >>>>>>     => 1@2
> >>>>>>
> >>>>>> This helper class would be useable in other contexts too (like NeoJSON).
> >>>>>>
> >>>>>> The advantage is that it does not change the STON (or JSON) syntax itself, it just add some functionality for those who want it.
> >>>>>>
> >>>>>> What do you think ?
> >>>>>>
> >>>>>> Sven
> >>>>>>
> >>>>>> PS: this probably needs some more testing
> >>>>>>
> >>>>>>> On 08 Jun 2015, at 17:16, Sven Van Caekenberghe <[hidden email]> wrote:
> >>>>>>>
> >>>>>>>> On 08 Jun 2015, at 17:03, Damien Cassou <[hidden email]> wrote:
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> Sven Van Caekenberghe <[hidden email]> writes:
> >>>>>>>>
> >>>>>>>>> I am not so sure we should add that.
> >>>>>>>>>
> >>>>>>>>> The JSON spec explicitly does not allow comments because of fear of abuse (that the comments would be used to add semantic meaning outside the spec).
> >>>>>>>> really? That's surprising. Comments in configuration files are very
> >>>>>>>> important. Even more when the configuration files are templates for new
> >>>>>>>> users.
> >>>>>>> I know some people are using STON in ways that I did not originally anticipate, that is of course cool, but writing configuration files was not the original goal. STON is a version of JSON that is closer to our object model.
> >>>>>>>
> >>>>>>> Like I said, I will think about it.
> >>>>>>>
> >>>>>>>> --
> >>>>>>>> Damien Cassou
> >>>>>>>> http://damiencassou.seasidehosting.st
> >>>>>>>>
> >>>>>>>> "Success is the ability to go from one failure to another without
> >>>>>>>> losing enthusiasm." --Winston Churchill
> >>>>>
> >>>
> >>
> >
> >
>
>


12