How about 'pure' for constants?
Gilles G.
schaouette at free.fr
Wed Dec 12 14:31:14 PST 2007
"alias" does not express the intent of the definition.
For example, when writing "alias foo = function int(int a, int b) {...};", the fact that the function does not have side effects is not explicit.
The expressions
pure real pi=3.14159;
pure real A = area(real diameter);
are much more informative.
Hxal Wrote:
> Don Clugston Wrote:
>
> > pure real pi = 3.141592564;
> > ...
> > pure int foo(int a, int b);
>
> Greetings fellow D community members. (since this is my first post.)
>
> I'm not terribly fond of either the enum or the pure idea.
>
> Perhaps this discussion is the perfect opportunity to revise the use of alias
> declarations. Suppose we changed the alias syntax to the form of "alias x = y;"
> We could amend its semantics to allow aliasing of values which would give us
> what this discussions seems to be about - named values taking no memory space.
>
> If we wanted to be able to specify the type we could further change the syntax
> to either "alias optionaltype x = y;" or "optionaltype alias x = y;".
>
> As far as pure functions go I guess the new alias could enable declaring a named
> function literal: "alias foo = function int(int a, int b) {...};";
> however I'd like to turn the attention of the community to the nifty pragma
> statement, which I find underused. Pragmas can be an excellent way to provide
> hints to the compiler without introducing new syntax, ie:
> pragma (pure, functionname);
> pragma (inline, functionname);
> or even pragma (pure); inside the function body.
>
> PS. My fondness of pragmas comes from my Ada programming background.
>
More information about the Digitalmars-d
mailing list