Introducing Cobra
Chuck Esterbrook
chuck.esterbrook at gmail.com
Wed Jan 2 10:39:26 PST 2008
On Jan 2, 2008 12:46 AM, David Brown <kplug at davidb.org> wrote:
> On Wed, Jan 02, 2008 at 12:39:04AM -0800, Chuck Esterbrook wrote:
> >On Jan 1, 2008 11:24 PM, David Brown <kplug at davidb.org> wrote:
> >> On Tue, Jan 01, 2008 at 10:48:11PM -0800, Chuck Esterbrook wrote:
> >>
> >> >I'm interested to hear your impressions, comments and questions.
> >>
> >> First impression question. Did you have any parsing problems not using the
> >> trailing ':' that python likes to use before indent blocks?
> >
> >No problems. Although it becomes required if you want to put a
> >statement on the same line:
> >
> > branch state
> > on State.On: print 'on'
> > on State.Off: print 'off'
>
> Is the ':' allowed? The vim python indent plugin seems to use the ':' to
> determine when to indent. Teaching vim how to color and indent a new
> language is always the frustrating part.
The indent for a colon language would be at least two keystrokes: [Shift] [;/:]
And maybe it's three?[Shift] [;/:] [Return]
The indent for Cobra is exactly two: [Enter] [Tab]
The colon is allowed because I don't want Python people to get
frustrated when starting out with Cobra. *But* It generates a warning
because Cobra has a theme of "syntax normalization" which I need to
write about. Essentially, most Cobra programs look mostly the same so
that code you see in a blog, email, wiki or in a project you just
inherited differs more by semantics than syntax. Examples rules
include:
* Classes must be capped
* Arguments and locals must start lower
* Blocks must be indented
I got the idea straight out of English where everything I read has
about the same syntax and consequently I dive immediately into
semantics regardless of what I'm reading.
The above rules generate errors. Some rules, like the extraneous
colon, generate warnings. Another example warning is treating return
like a function call instead of a statement: return(x)
Should be: return x
Back to indentation: I think you're okay in vim with [Return] [Tab]
but let me know if that's a problem. Indentation can be one tab or 4
spaces. No mixture of tabs and spaces on the same line as that causes
hell in Python.
-Chuck
More information about the KPLUG-LPSG
mailing list