On Sat, Nov 24, 2001 at 09:20:08PM +0200, Oren Ben-Kiki wrote:
| I wrote:
| > Forget this issue. We already have a way to do it (smack self on head
| > several times - I was the one who introduced it!).
|
| I thought about it some more - even wrote the wording for allowing an
| implicit {} and [] syntax for maps and lists (it is in text format below if
| you are interested).
I kinda like it, although, I'd use comma for the
separator and not allow the separator to be changed.
| The only problem in the current scheme is that the transfer method name
| contains a non-alnum character, which isn't allowed by the productions;
| using an implicit transfer method this isn't a problem, there's only one
| transfer method (!map or !seq) and the separator is specified in the scalar
| itself. I guess we could relax the productions to allow for:
|
| tld.domain.type.etc<any non space>
I'd rather not relax. Make the default separator a comma,
and if they don't like it they can use the long form.
| We've already seen several useful examples for this (seq(type), seq;,
| java.lang.Integer[], etc.).
Let's keep these reserved till 1.1 untill we have a
schema system and can use these non-alphas for that
purpose. If we open it up, then we can't do nice
things later in a standard way.
Below is nice, given (a) the separator is fixed
as a comma "," to be consistent with most languages,
and (b) the stuff between the commas is pushed back
through the implicit type system.
lst: [ ',',two]
| Name: org.yaml.seq
| Regexp: '[.*]'
|
| This transfer method is used by default for sequence nodes unless they are
| given an explicit transfer method property. It should deserialize the node
| to any native native sequence-like data type satisfying the requirements for
| the TODO - sequence type family (e.g., array in Perl, list or tuple in
| Python, array or vector in Java).
|
| Specifying this as an explicit transfer method is required for the
| serialization of in-line sequences and for specifying a sequence as a map
| node (for sparse sequences).
|
| Sometimes a sequence is very short and contains "simple" values. YAML allows
| such sequences to be written in compact form using any scalar node style
| with an implicit seq transfer method. A plain scalar surrounded by '[' and
| ']' is taken to contain a sequence. The character immediately following the
| opening '[' specifies the separator between equence entry values. If this is
| a space character (#x20) then values are seperated by
| any white space. There is no way to escape the separator character. White
| space is trimmed from the start and end of values, but is preserved within
| them.
|
| Note that splitting the text into entries is done after the parser has
| extracted the text from the scalar node according to its style. Thus it is
| possible to use arbitrary characters in an implicit sequence using an
| escaped scalar style, but there is no way to prevent a separator character
| from starting a new entry or prevent white space from being trimmed from the
| values.
|
| Applying the seq transfer method to an empty scalar also provides a natural
| syntax for representing an empty sequence.
|
| # The following is an empty
| # top level sequence.
| --- !seq
| ---
| # An empty sequence.
| empty sequence: !seq
| another one: []
| # The following is a scalar style node
| # which is deserialized to a sequence
| # with three entries.
| short: [ Brian Clark Oren ]
| # The following sequence also has
| # three entries.
| long: [ ; Brian Ingerson ; Clark Evans ; Oren Ben-Kiki ]
|
| In some applications large sequences may contain only a small number of
| non-null entries. While it is possible to serialize such sparse sequences
| using the null implicit transfer method, this is awkward. YAML allows to
| serialize such sequences using the map node style with an explicit sequence
| transfer method. The only supported keys are integers, serving as
| zero-based sequence entry indices.
|
| # The following map style node is
| # deserialized to a sequence, with
| # unspecified entries containing
| # a null value.
| sparse sequence: !seq
| 2: Third entry
| 4: ~
| # The following sequence node is
| # deserialized into an identical
| # in-memory sequence, which has
| # a seperate identity.
| identical sequence:
| - ~
| - ~
| - Third entry
| - ~
| - ~
|
| Name: org.yaml.map
| Regexp: '{.*}'
|
| This transfer method is used by default for map nodes unless they are given
| an explicit transfer method property. It should deserialize the node to any
| native native map-like data type satisfying the requirements for the TODO -
| map type family (typically a hash table of some sort, e.g. hash in Perl).
|
| Specifying this as an explicit transfer method is required for the
| serialization of in-line maps.
|
| Sometimes a map is very short and contains "simple" key:value pairs. YAML
| allows such maps to be written in compact form using any scalar node style
| with an implicit map transfer method. A Plain scalar surrounded by '{' and
| '}' is taken to contain a map. The character immediately following the
| opening '{' specifies the separator between key:value pairs. If this
| is a space character (#x20) then pairs are seperated by any white space.
| There is no way to escape the separator character. White space is trimmed
| from the start and end of keys and values, but is preserved within
| them.
|
| Note that splitting the text into key:value pairs is done after the parser
| has extracted the text from the scalar node according to its style. Thus it
| is possible to use arbitrary characters in an implicit
| map using an escaped scalar style, but there is no way to prevent a
| separator character from starting a new key:value pair, prevent the ':' from
| ending a key and starting a value, or prevent white
| space from being trimmed from the keys and values.
|
| Applying an explicit map transfer method to an empty scalar provides a
| natural syntax for representing an empty map.
|
| # The following is an empty top level map.
| --- !map
| ---
| # Empty maps:
| empty map: !map
| another one: {}
| # The following is a scalar style node
| # which is deserialized to a map with two keys.
| short: { Content-Type:image/gif transfer-encoding:base64 }
| # The following map also has two entries.
| long: {; Content Type : image/gif ; transfer encoding : base64 }
|
| _______________________________________________
| Yaml-core mailing list
| Yaml-core@...
| https://lists.sourceforge.net/lists/listinfo/yaml-core
--
Clark C. Evans Axista, Inc.
http:\\axista.com 800.926.5525
Collaborative Software for Project Management
Patriotisim means protecting core values during difficult times,
not pasting a flag on your SUV and repealing the Bill of Rights.
|