|Newbie questions about Pliant
Modules and Functions
|Message posted by maybe Marcus on 2001/12/14 22:30:55
|Hubert Tonneau wrote:
> In Pliant, methods is only a syntax issue: it's a way to write the first
> parameter of the function before the name of the function.
It seems that, as far as the way one would call a method is concerned, the
difference seems to be more than syntactical. For instance, given the following
(working) program fragment:
method page show disc_id aluno_id
arg_rw HtmlPage page ; arg Str disc_id ; arg Str aluno_id
the method 'show' has three arguments: page, disc_id, and aluno_id.
However, this method is called with two explicit parameters in the following
eif (virtual_path parse "/show/" any:(var Str disc_id) "/" any:(var Str aluno_id) "/")
show disc_id aluno_id
How does this work?
|Message posted by maybe Hubert Tonneau on 2001/12/14 23:30:11
|> How does this work?
'implicit' is also syntax only.
function foo x y -> z
arg Int x y z
z := x + y
console (3 5) eol
Now the name of the function is implicit.
Basically implicit means if we fail to compile, then try to add the provided
keyword in front, and see if it works.
|Message posted by maybe Hubert Tonneau on 2001/12/14 23:51:07
In a language, some features are only intended to improve easyness to read
There is absolutely no difference between a field and a function, so
there is absolutely no reason to have a different syntax.
Think about the length of a string. Is it a function, or a field ?
It depends about the implementation ... and it may change over time.
Same for the fields of a Complex number.
So, if we have only functions, then if we have a record 'r' with a field
'name', we have to write name:r instead if r:name and it's not convienient
because it's easier from anybody reading the program from left to right to
meet 'r' first.
So, basically we end with some functions need to be written with the
keywords on the right because it's easier to read, and here are the methods.
All object programming related arguments are ideology.
In some programs, there is a keyword that appears nearly everywhere (your
exemple with 'page' argument is very good).
For a human, the program will be easier to read if the keyword is removed
everywhere because a human will have no trouble it reinsert it.
Here is the implicit.