[M3devel] C-like syntax for Modula-3 [was Re: "target specific pragmas"?]

Darko darko at darko.org
Tue Feb 19 11:04:09 CET 2008


I agree that there should be a pre-processor between M3 syntax and C  
syntax, but this should also be integrated into the build system so  
that it is transparent. I think the '.mc' extension is already taken  
though, which is a bummer.

I think we should also be aiming to use this tool to automatically  
convert C header files (with limitations) to M3.

The more I think about it the more I wonder if C programers will  
swallow it: for example VAR params?

Further comments are embedded...

On 18/02/2008, at 3:26 PM, Jay wrote:
> I've been trying to stay out of this...

I would have though your input was most appropriate since your a  
member of the target audience.

> If a comment at the top of the file can make the Modula-3 syntax  
> more like C then..

Not really what we're aiming for. We're looking for a separate C like  
syntax in separate files.

> replace = with ==

yes

> replace := with =

yes

> make assignment an expression

no, that changes the abstract syntax, which is something we're trying  
to avoid.

> lowercase the keywords

yes

> try to make braces work (with some alteration for C)

yes

> use type name instead of name : type

yes

> separate function parameters with commas and require each to state  
> its type

yes

> for that matter, subset C and require all declarations be separate  
> like that?

Do you think C programmers would object?

> put back ++, --, -=, +=, etc.

yes

> superset C and let . be used in place of ->

yes

> new coding style is four space indent with opening braces on their  
> own line :)

I don't do that even in C

> Hm. I think if anyone really wants to do this, instead of nit  
> picking about Modula-3 syntax here and there, go about it in a  
> slightly different way?

We're really not looking to change M3 in any way, just provide an  
alternate syntax.


>  Pick apart what defines Modula-3 through much discussion.
>  Optional safety -- probably but that for these purposes
>  optional garbage collection  -- maybe that too
>  "object orientation" that is a subset of C++
>    try to use C++ syntax?
> generics (generic modules)
>  independently and relatively easily parsable interface definitions  
> (!)
>    these are both important, but I think "independent" is more  
> important
>    and "relatively easily" could be omitted for the goals of this  
> exercise
>  compiles to native code
>  sizeof(integer) == sizeof(address) (minor detail)
>  built in sets and good enumerations
>  arrays; I don't like them starting at non-zero, but enums for their  
> index are interesting
>
> Take the existing definition of C and alter it to have these  
> characteristics very very much like Modula-3 but with very very very  
> much Modula-3 syntax









More information about the M3devel mailing list