From: Clark C . E. <cc...@cl...> - 2002-05-20 11:33:02
|
On Mon, May 20, 2002 at 02:09:59AM -0400, Oren Ben-Kiki wrote: | I slept over this... and I think *true is a bad idea. | I see the advantage: being able to write booleans in a | readable way. But I think this is the wrong way to achieve it. The rationale for this emerged using how I currently implement enumerations within my data. For example: --- !http://clarkevans.com/^task-list - name: Read-email status: &001 !^status Continuous hours: 1 - name: Write Congress person status: &002 !^status In-Progress hours: 2 - name: Read news status: *001 # Continuous hours: 3 Thus, the anchor here is a typed node and later occurances of the enumeration is done via alias with a comment. This is a very clean way to emit. The actual enumeration can be put in a schema for validation and/or visual editors. | If we ever want to use the same trick for other | enum-like types, this could be a problem. Well, *bool is a natural extension of the above mechanism if you ask me... | --- | - *true | - &true bloop | - *true This one is rather clear, the user has re-defined what *true means. Not a problem. In perl, "int" is a built-in; however, you can shadow it. x = int("3") # converts 3 to an integer type int = "I am a string now." y = int("3") # syntax error, int is a string. This may seem problematic, but it really isn't. Keywords can be added without breaking old code... | - Additional complexity. | | The above creates a new mechanism, "predefined anchors". This means that it | is no longer sufficient to specify the type families to be able to fully | grok a YAML file. We would also have to specify a set of pre-defined anchors | the document relies on. Well, those pre-defined can be in the YAML spec. If we increase the number of pre-defined anchors, we will have to increment the YAML version (the minor version). | - Slippery slope. | | Where does it stop? *pi, *e and *i? *noon, *midnight and *tea-time? *gpl and | *bsd? Please. Let's not start down this road. Ok. | canonical, explicit: 0|1 | implicit: :[tT]rue|:TRUE|:[Ff]alse|:FALSE | implicit: :[Yy]es|:YES|:[Nn]o|:NO | | examples: | | trues: | - !bool 1 | - :true | - :True | - :TRUE | falses: | - !bool 0 | - :false | - :False | - :FALSE Ok. This isn't bad, although I don't particulary like the use of the colon (:) as we already have given this meaning. Best, Clark -- Clark C. Evans Axista, Inc. http://www.axista.com 800.926.5525 XCOLLA Collaborative Project Management Software "There lies before us, if we choose, continued progress in happiness, knowledge, wisdom. Shall we, instead, choose death, because we cannot forget our quarrels?" -- Albert Einstein and Bertrand Russell in 1955 paper regarding nuclear weapons. http://www.noradiation.org/caldicott/book-02.html |