Standards For Syntax

24 views
Skip to first unread message

Kurtis Rainbolt-Greene

unread,
Mar 7, 2012, 4:38:17 PM3/7/12
to magpi...@googlegroups.com
I've noticed a few changes in how the code in `lib/` is written:

  - Sometimes comments are denoted with `//`, sometimes with `///`
  - Sometimes blocks are indented by 4 spaces, sometimes 2 spaces
  - Sometimes classes get their own file, sometimes multiple classes are in a single file (SEE: IO especially)

Has anyone attempted to write a style guideline for Magpie?

Bob Nystrom

unread,
Mar 13, 2012, 1:25:17 AM3/13/12
to magpi...@googlegroups.com
On Wed, Mar 7, 2012 at 1:38 PM, Kurtis Rainbolt-Greene
<kurtisrain...@gmail.com> wrote:
> I've noticed a few changes in how the code in `lib/` is written:
>
>   - Sometimes comments are denoted with `//`, sometimes with `///`

// comments are just regular comments.

/// comments are "doc" comments.

They can only appear in certain places (right inside method bodies and
class bodies) and are parsed by the parser. There isn't much support
for them yet, but there are some basic reflection methods for getting
the docs for methods.

>   - Sometimes blocks are indented by 4 spaces, sometimes 2 spaces

They should all be four spaces. If they aren't it's a bug. Let me know
or send me a pull request. :)

>   - Sometimes classes get their own file, sometimes multiple classes are in
> a single file (SEE: IO especially)

Files are modules in Magpie: they are the unit of import. So there's a
bunch of stuff in io mainly so that if you import io, you get it all.
You can do that while splitting things up into multiple files by using
export, but I haven't done that because it's still pretty small. If it
gets too big we definitely should.

> Has anyone attempted to write a style guideline for Magpie?

I try to be consistent, but no, there's definitely no style guide. The
language is still in flux, so that might be getting a bit ahead of
ourselves. :)

- bob

Reply all
Reply to author
Forward
0 new messages