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

What is Rascal's calling convention for main? #864

Closed
PaulKlint opened this issue Sep 9, 2015 · 4 comments
Closed

What is Rascal's calling convention for main? #864

PaulKlint opened this issue Sep 9, 2015 · 4 comments

Comments

@PaulKlint
Copy link
Member

What happens when pushing Run as ... Rascal Application?

The interpreter calls main(), but I remember that keyword parameters are handled by the interpreter (but how are they set?)

Compiled code calls main([]), for reasons that I do not recall but it may be to get some similarity with Java's main.

Any opinions which way to go?

@DavyLandman
Copy link
Member

There are different stories:

  • From the rascal-shell: if you have defined a main module in the RASCAL.MF it will run the main() function or the function defined in the RASCAL.MF to run. It will also translate all command line args (-startAt 20) to keyword params for that main function (startAt = 20). (actually there are even more cases in the rascal-shell)
  • Run-as inside eclipse: there are no command line arguments, so no keyword parameters. We could pass environment flags? Or stuff from the run configuration? But for now, no keyword parameters.

I'm not so sure that should be passed into the list args? I quite like the parsing of arguments as kwargs, it's the same as most modern languages are doing (providing a getopt kind of interface).

@jurgenvinju
Copy link
Member

In Eclipse the commandline args could be passed in a text box in the run configuration, just like this is done now for Java programs. Then we would have the same behavior for both instances.

@PaulKlint
Copy link
Member Author

@jurgenvinju with "command line args" you mean keyword parameters?

@PaulKlint
Copy link
Member Author

Now I remember why I had this different calling convention in mind: it was already used in the original Rascal design document (2008-2009)! Here is one of the examples (starting at p28):

public void main(list[str] argv){
  int N = toInt(argv[0]);
  map[int,int] squares = {};
  for(int I : [1 .. N]){
     squares[I] = I * I;
  }
  println("Table of squares from 1 to ", N);
  println(squares);
}

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

3 participants