Page 1 of 1

Expression evaluation not a statement?

Posted: Tue May 12, 2015 8:20 pm
by joe
Unless I am missing something (very possible) I cannot see that the TutorialD grammar allows a statement to be an expression. This would seem to be the case given that an expression must be entered into the DBBrowser without a trailing semi-colon.

I am wondering what the rationale is for this? In SQL you can obviously enter an expression and see the result, and it is also considered a statement. It would seem that TutorialD is more like PL/SQL in that it wants you to do a "load" into an array variable first - similar to SELECT...INTO in PL/SQL?

Joe

Re: Expression evaluation not a statement?

Posted: Fri May 15, 2015 12:50 pm
by Dave
Yes, the Tutorial D grammar presumes that expressions will be assigned to variables or passed to operator invocations. I don't know the rationale for that, though I can guess that it's motivated by an inclination toward (but not a requirement for) operators that are pure functions which have no side-effects. If expressions were always side-effect-free, there would never be a reason to evaluate an expression as a statement because it wouldn't do anything.