bsdz / matrixy

Automatically exported from code.google.com/p/matrixy
0 stars 0 forks source link

Enable function dispatching by barewords #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Name of feature to implement: Dispatching by barewords

Matlab/Octave (or both): I think it's only Matlab (some of it works in
Octave too)

Component: Parser

Other Information:

Functions should be able to be dispatched by barewords:

{{{
quit();
quit;    % Should be same!
}}}

Octave and Matlab allow this. However, Matlab also seems to take this a
step further and allows parameters to be passed as barewords too:

{{{
help("whatever")
help whatever   % Should be same!

Foo("This is a string")
Foo This is a string  % Should be same!
}}}

At the moment, the parser treats all bare words as identifiers in an
expression. Need to modify this so we go through the normal sub_or_var
logic and differentiate these calls as function calls (unless a lexical
variable of that name exists). Cases:

{{{
x      % variable x, if exists. Function x otherwise. handled in sub_or_var
x()    % Same
x args % always function x. Treated as x("args")
}}}

Make sure to modify the term rule to force all identifiers to be treated as
sub_or_var instead of primary or identifier. This will enable predefined
constants like pi() to be used in expressions as just "pi".

Original issue reported on code.google.com by wknight8...@gmail.com on 3 Mar 2009 at 8:28

GoogleCodeExporter commented 9 years ago
As of r135, most of my concerns above are resolved and the system is basically
implemented. We can create other specific tickets for individual issues related 
to this.

Original comment by wknight8...@gmail.com on 19 Mar 2009 at 10:43