From: Clark C. E. <cc...@cl...> - 2002-09-18 18:00:17
|
I've fell victim to the map-seq trap again... --- - this: - is - bad I was wondering in which cases using this short-cut gives a syntax error; and if the syntax error is necessary (or if it can DWIM?). Can keys start with a minus followed by a space? Clark |
From: why t. l. s. <yam...@wh...> - 2002-09-18 18:37:32
|
Clark C. Evans (cc...@cl...) wrote: > I've fell victim to the map-seq trap again... > > --- > - this: > - is > - bad > > I was wondering in which cases using this short-cut gives > a syntax error; and if the syntax error is necessary > (or if it can DWIM?). Can keys start with a minus > followed by a space? Since sequences are prefixed by a dash, couldn't we require that the dash be indented to a level at least as deep as the previous, but actually count the dash as indentation? so: --- - this # indent level: 1 - is - valid --- - this: # indent level: 1 (seq), 2 (map) is: still valid --- - this: # indent level: 1 (seq), 2 (map) - is # indent level: 3 - valid --- - this: # indent level: 1 (seq), 2 (map) - is: # error.. dash starts lower than the map's indentation - not - valid I think many users would be surprised to find that example 3 is currently invalid. There's probably a way to trip this up, but i can't think of how. Plus, we're all ready sort of doing this with the sequence-mapping shortcut. The dash and the space are counted as indentation in the shortcut. All this does is extend that logic to give the dash further definition as a marker for indentation. This is really easy to trip upon. I can guarantee that anyone who uses the sequence- mapping shortcut will trigger it. _why |
From: Brian I. <in...@tt...> - 2002-09-18 19:08:51
|
On 18/09/02 12:47 -0600, why the lucky stiff wrote: > Clark C. Evans (cc...@cl...) wrote: > > I've fell victim to the map-seq trap again... > > > > --- > > - this: > > - is > > - bad > > > > I was wondering in which cases using this short-cut gives > > a syntax error; and if the syntax error is necessary > > (or if it can DWIM?). Can keys start with a minus > > followed by a space? > > Since sequences are prefixed by a dash, couldn't we require > that the dash be indented to a level at least as deep > as the previous, but actually count the dash as > indentation? > > so: > > --- > - this # indent level: 1 > - is > - valid > --- > - this: # indent level: 1 (seq), 2 (map) > is: still valid > --- > - this: # indent level: 1 (seq), 2 (map) > - is # indent level: 3 > - valid > --- > - this: # indent level: 1 (seq), 2 (map) > - is: # error.. dash starts lower than the map's indentation > - not > - valid > > I think many users would be surprised to find that example 3 is currently invalid. > > There's probably a way to trip this up, but i can't think of how. Plus, we're > all ready sort of doing this with the sequence-mapping shortcut. The dash and > the space are counted as indentation in the shortcut. All this does is > extend that logic to give the dash further definition as a marker for indentation. > > This is really easy to trip upon. I can guarantee that anyone who uses the sequence- > mapping shortcut will trigger it. I don't think I've ever triggered it. --- - foo: - bar # is simply a collapse of - foo: - bar I can see the human problem here, though. I'd like to hear Oren's thoughts. We then have to allow: --- foo: - bar Probably. I'd rather print a smart error message, and be done with it. Cheers, Brian |
From: Clark C. E. <cc...@cl...> - 2002-09-18 21:32:27
|
On Wed, Sep 18, 2002 at 12:08:11PM -0700, Brian Ingerson wrote: | We then have to allow: | | --- | foo: | - bar | | Probably. I'd rather print a smart error message, and be done with it. Ouch. Yes; I guess just making the error message smart would be cool. Clark |