From: Ionous <li...@io...> - 2007-04-19 17:00:06
|
i've been writing about YAML on my blog on and off, and wrote a little bit on this topic<http://www.ionous.net/2007/01/31/yamls-missing-type/>if anyone's interested.... my argument there was that since any language using YAML to parse data, already has to do some minimal negotiation of types as data gets read in ( for error handling for instance ) treating strings and scalars uniformly could help smooth out some of the implicit typing problems that can occur. rather than eliminate implicit typing tho, my thought was you implicitly type both scalars and strings. basically just treating strings as a method to allow the inclusion of YAML operators in a scalar value.... meaning both "3" and 3 are the same thing. i know, as programmers, that sounds a bit unusual, but i think it would actually make a bunch of sense to the average, non-programmer / document author.... and even has a little bit of precedence some places.... html attributes, for instance, are always quoted whether the dom is going to treat the value as a number, a string, or enum -simon. On 4/18/07, Kenneth Downs <ke...@se...> wrote: > > Clark C. Evans wrote: > > Kenneth, > > > > short answer: > > You should be able quote those Y/N items to force them > > to be a string. > > > > OK, this is what I'm not doing now. > > > long answer: > > You might be able to configure your parser to not "implicitly > > type" Y/N as a boolean value. > > > > This had crossed my mind, but I was hoping you wouldn't say that :( > > > longest answer: > > > You've hit the #1 usability prooblem with YAML, it's called "implicit > > type resolution" and different implementations are doing it > > differently. > > > > The original goal was to make it easy to type in integers and have > > them show up as integers w/o littering your text with "!!int". > > Unfortuntely, where that line should be drawn is a bit hard. > > > > Hard to argue with the original goal. > > > In the next pass of YAML, I am going to recommend that all parsers > > _only_ do implicit typing on: > > > > (a) symbolic values, such as <<, which can be used to > > augment the YAML syntax /w very nice hooks > > > > (b) numbers, "true" "false" and "null", following > > the JSON standard (for compatibility) > > > > What about adding the feature which I thought from the docs was already > present, a kind of variable declaration that tells the parser how to > handle certain names. In my case I would want to say > > "For name:value combinations where name=="primary_key" make value a > string." > > This ought to give the best of all worlds, in that it would allow > > a) implicit typing, which has some historical weight and strong arguments > b) name-level overrides, perhaps even descendent names like CSS > c) value-level overrides, which I believe are already in there (putting > !!int everywhere?) > > > > At least, this should, IMHO, be the default. I think Ingy begs > > to differ and believes the default should be *all strings* with > > no implicit typing. What ever we come up with, getting there > > is sure to be unpleasent; but probably far less unpleasant than > > the current state of affairs. > > > > Cheers, > > > > Clark > > > > > > > > On Tue, Apr 17, 2007 at 10:59:16AM -0400, Kenneth Downs wrote: > > | Hello! > > | > > | I am a recent convert to YAML, using spyc to load YAML files to PHP > > | arrays. Very very nice. > > | > > | There are many places where we have assignment pairs that look like > > | "primary_key: Y" or "uisearch: Y", and YAML is interpreting these to > be > > | booleans and making them into 1/0 assignments. > > | > > | It seems that with TAGs I ought to be able to force those particular > > | keys to read as strings. But alas, the documentation, while very > > | complete, is also very abstract and lacks (as far as I could find) an > > | example of this basic task. Can anybody clue me in? > > | > > | Thanks. > > | > > | -- > > | Kenneth Downs > > | Secure Data Software, Inc. > > | www.secdat.com www.andromeda-project.org > > | 631-379-7200 Fax: 631-689-0527 > > | > > | > > | > ------------------------------------------------------------------------- > > | This SF.net email is sponsored by DB2 Express > > | Download DB2 Express C - the FREE version of DB2 express and take > > | control of your XML. No limits. Just data. Click to get it now. > > | http://sourceforge.net/powerbar/db2/ > > | _______________________________________________ > > | Yaml-core mailing list > > | Yam...@li... > > | https://lists.sourceforge.net/lists/listinfo/yaml-core > > > > > -- > Kenneth Downs > Secure Data Software, Inc. > www.secdat.com www.andromeda-project.org > 631-379-7200 Fax: 631-689-0527 > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Yaml-core mailing list > Yam...@li... > https://lists.sourceforge.net/lists/listinfo/yaml-core > |