Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thoughts on script parameter notations #77

Open
AndreVanDelft opened this issue Mar 31, 2015 · 1 comment
Open

Thoughts on script parameter notations #77

AndreVanDelft opened this issue Mar 31, 2015 · 1 comment

Comments

@AndreVanDelft
Copy link
Owner

Currently script parameters may be enclosed in parentheses, but a notation with just comma's is also supported:

println("hello")
println, "hello"

the second notation would be useful in case of an implicit conversion with more than 1 parameter (to be implemented using an implicit conversion with a tuple), e.g.,

"(", nws

In a syntax definition could be implicit for parse("(", nws) with nws a switch for "no white space" (before the symbol).

IMO the comma notation would only be good for such implicit script calls.
For other purposes, with an explicit name of the called script, it would be clearer to use a Smalltalk-like colon notation:

println: "hello"

If there are multiple parameters, these would be separated by comma's. E.g. a poisson process spawner would be in the old syntax

spawnEvery( 5*minute, [ aScript] )

In the new syntax:

every: 5*minute, spawn: [ aScript ]

or even with a closing tag:

every: 5*minute, spawn: [ aScript ] :end

Such a script could be defined as:

every:spawn:end[T](duration: double, process: Script[T]) = ...

Note that in the definition we would not write the extra colon for the trailing tag, and in case there is only one parameter we would not write a colon at all.

Could the colon notation also support variable argument lists? Probably, but then for the group of arguments the tag would not be repeated. E.g.,

myPrint: "a", "b", "c"

would call

myPrint( args:String* )
@AndreVanDelft
Copy link
Owner Author

I am in doubt about

every: 5*minute, spawn: [ aScript ]

I now tend to think the multiplicative expression should be enclosed in parentheses, as in:

every: (5*minute), spawn: [ aScript ]

The reason is that if it were the last parameter, symbols like + would be ambiguous.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant