Skip to content

Thoughts on script parameter notations #77

Open
@AndreVanDelft

Description

@AndreVanDelft

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* )

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions