As we go about creating more examples in ParaSail, and compare with various other recent languages, we find the use of these three distinct terms not particularly helpful, and certainly more verbose than most other languages. On the other hand, the terms do communicate something about the appropriate use of the operations.
We are now leaning toward replacing all three terms with the term "func". Our sense is this would give the syntax a somewhat less heavy, and perhaps more modern feel. We would retain the requirement to echo the term at the end of the operation, hence:
func GCD(X, Y : Integer) -> Integer is case X =? Y of [#less] => return GCD(X, Y mod X); [#equal] => return X; [#greater] => return GCD(X mod Y, Y); end case; end func GCD; func Print(F : ref var File; X : Integer) is if abs X >= 10 then Print(F, X/10); end if; Print(F, '0' + (X rem 10)) end func Print; func "|"(X : Set; E : Elem) -> Set is return Union(X, Make_Set(E)); end func "|";
The above three "func"s would be "function GCD," "procedure Print," and operator "|" using the current ParaSail syntax. Given that we are already abbreviating "constant" to const and "variable" to var in ParaSail, it doesn't seem inconsistent to adopt a standard abbreviation here for function/procedure/operator, and func is one that appears in a number of languages.
Now this is an issue about which anyone and everyone probably has an opinion...
Why not using `feature' which is a terminology used in Eiffel for the past 25 years, or just simply `routine'.
ReplyDeleteI suppose the first question is whether to use a single term for all three kinds of operations. The second question is what term to use.
ReplyDeleteEiffel doesn't really use the term "feature" in this way. They instead rely on the presence of "()" to indicate they are defining an operation as opposed to a component, and use "feature" as a dividing line to separate the class header from the class definitions.
One explicit goal in ParaSail has been to use terms that are in wide use in multiple languages, and hopefully easily recognizable and intuitive, rather than relying on new or rarely used terminology.
Unfortunately, these sorts of things are very subjective...
In user code, "func" for either "function" or "procedure" works for me; Ada uses "subprogram" in a similar way in the manual (not the syntax).
ReplyDeleteFor operators, I'd prefer something more than just the presence of quotes.
> For operators, I'd prefer something more than just the presence of quotes.
ReplyDeleteAny suggestions? e.g.:
op "*"(Left, Right : Integer) -> Integer;
oper "*"(Left, Right : Integer) -> Integer;
operator "*"(Left, Right : Integer) -> Integer;
Thanks,
-Tuck
Ok, we have settled on "func" for functions and procedures and "op" for operators. The latest ParaSail reference manual incorporating these changes has been posted to the Google group:
ReplyDeletehttp://groups.google.com/group/parasail-programming-language
I just realized that in Ada, the only syntax difference between operators and functions is the presence of quotes (I knew that before, I just didn't think of it in this context). So there is precedence for that, and it's never bothered me.
ReplyDeleteIt does seem that the presence of "op" instead of "func" makes things clearer. But I could go either way.
Sorry to partially flip-flop on you :(.
I think the use of "op" rather than "func" does clarify things, and since operators have special significance to the syntax, it seems worth distinguishing them. Most languages that allow user-defined operators have some sort of unique syntax for declaring them, and just using quotes is perhaps more subtle than necessary.
ReplyDelete