Re: Force a value:pair assignment to be string?
Kenneth Downs <[email protected]>
| Newsgroups | gmane.text.yaml.general |
|---|---|
| Message-ID | <[email protected]> |
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 > | [email protected] > | 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/