Pragma syntax

Lukas Renggli renggli at gmail.com
Fri Aug 18 11:37:50 UTC 2006


> Why isn't the syntax for pragmas something like this...
>
> <pragma: A value: 10>
> <pragma: a:b: value: {1. 2}>
> or maybe, <pragma: a: 1 b: 2>

I don't see how this could help to avid typing errors? Moreover it
makes pragmas much more verbose, incompatible with other
implementations, and harder to read.

> But if I've made a typo...
>     <primitive: 'a' moduel: 'b'>
> I get a pragma. Which is almost certainly not what I wanted.
> Of course, the compiler could check that if the first part is primitive: then
> the second part is module: , but what about...
>     <primitiv: 1>  [sic]
> Once again I get a pragma.

I wouldn't do a distinction between pragmas and primitives. In my
opinion primitive pragmas (in your language code-generating angle
bracket constructs) are the same as any other pragma, the only
difference is that they are interpreted by the compiler. This can be
done in a very clean way as I proposed in the FFI thread.

Now, assuming that primitive-pragmas are the same as any other pragma,
how can we avoid typing mistakes in pragma declarations? Actually this
problem is not new, it also happened to me several times. Let me
propose two different solutions:

- In VisualWorks you have to declare pragmas (using pragmas) if you
want to use them. This would solve the problem, though I don't
particularly like it because Smalltalk is not about declaring things.
It also creates new dependencies between code that is not easy to cope
with. So I don't think this would be a good solution.

- Introduce a similar correction mechanism for pragmas as we do for
message selectors that are unknown to the system. This would pop-up a
message in case the pragma is not already known to the system and
allow the user to proceed or correct it. I think this would be a nice
solution, though it has the drawback that once you misspelled your
pragma you don't get a warning anymore.

What do you think?

Cheers,
Lukas

-- 
Lukas Renggli
http://www.lukas-renggli.ch



More information about the Squeak-dev mailing list