print ambiguity

"Mark Hahn" <[email protected]>
Newsgroups gmane.comp.lang.prothon.user
Message-ID <[email protected]>
If you put the word "print' on a line by itself, the meaning is ambiguous
under the new function-as-command proposal.  It could mean evaluate the
print function object or it could mean call it.  Since the Parser doesn't
know which objects are functions, much less which are commands, it would
have to decide at parse time whether all labels by themselves on a line
should be attribute evaluations or command function calls.  We need to
decide.

1) If we decide it always means a command then we could use the print
command on a line by itself to print a blank line as always, but then in the
console we couldn't just enter a single variable to see it's value.

2) If we decide it always means a variable we would have to type "print()"
to print a blank line and the console could be used as always.

3) We could do solution number 1 but kludge the console to treat the entry
of a single label as a special evaluation and not parse that line as a
normal Prothon statement unless it is a command.  In effect we would change
to line from "x" to "print x".

I will do kludge number 3 for now.  Let me know if anyone has a problem with
this.

This solution will mean that a variable on a line by itself in a script,
which used to be a harmless non-operation, will now cause an exception
saying that the variable is not a valid command.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.