Open AndreVanDelft opened 8 years ago
while
may be preceded by an annotation; if
cannot have that without cluttering up the syntax.
I think now we need an uniform approach for both.
if @gui: chooser.showSaveDialog(null)==FileChooser.Result.Approve
then ... else ...
would work. Then also allow for
while @gui: (chooser.showSaveDialog(null)==FileChooser.Result.Approve)
The latter would have the same meaning as having the annotation in front of while
.
Neither will work due to the nature of the predicate. It is a piece of pure Scala code on the VM value, not a script, hence cannot be annotated. Possible solution is to use do-then-else
instead; the predicate of do
is a script:
do selectFile(chooser) then foo else bar
selectFile = @gui: {!chooser.showSaveDialog(null)==FileChooser.Result.Approve!} ~~(result: Boolean)~~> if result then [+] else [-]
I disagree: syntactically it is possible, and semantically the annotation would as usual be executed when the if
or while
is activated, and it can do its work using the there
pointer.
Thus while @a: c
would do exactly the same as @a: while c,
and if @a: c then ...
would be similar.
Indeed, seems possible. On Feb 19, 2016 3:16 PM, "André van Delft" notifications@github.com wrote:
I disagree: syntactically it is possible, and semantically the annotation would as usual be executed when the if or while is activated, and it can do its work using the there pointer. Thus while @a: c would do exactly the same as @a https://github.com/a: while c, and if @a: c then ... would be similar.
— Reply to this email directly or view it on GitHub https://github.com/scala-subscript/subscript/issues/35#issuecomment-186209101 .
The eyetest Login class contains:
The call to showSaveDialog should be done in the gui thread, so an @gui: annotation would be needed:
However, other than with while, it seems to be hard to allow for this in front of
if:
, since an annotation is a termRaw, and anif
construct is anExpr7
. Maybe it can be done.For the time being the programmer could enclose the
if
construct in braces. Or maybe it would be convenient to writeThat syntax could be allowed without ambiguity problems. But maybe it would not be a good idea.
BTW it would be good if the implicit
there
parameter for the call togui
would inform the caller that it has some executable code, i.e. a code fragment, or a while, if, annotation, script call (and maybe more).This definition should than also become more specific than just
N <: CallGraphNode
.