Expression evaluation not a statement?

This forum is for any questions about the language Tutorial D or the Rel implementation of it.
Post Reply
joe
Posts: 1
Joined: Tue May 12, 2015 7:59 pm

Expression evaluation not a statement?

Post 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
Dave
Site Admin
Posts: 372
Joined: Sun Nov 27, 2005 7:19 pm

Re: Expression evaluation not a statement?

Post 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.
Post Reply