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

Enhancement: treat decorated routine as first-class citizen #365

Open
dumblob opened this issue Feb 14, 2015 · 6 comments
Open

Enhancement: treat decorated routine as first-class citizen #365

dumblob opened this issue Feb 14, 2015 · 6 comments

Comments

@dumblob
Copy link

dumblob commented Feb 14, 2015

Currently, only routines can be first-class citizens:

0$ dao -e 'routine @d(f(args): routine) {io.writeln("@d")}; r=routine() {io.writeln("r")}; r()'
r
= none
0$ dao -e 'routine @d(f(args): routine) {io.writeln("@d")}; @d routine r() {io.writeln("r")}; r()'
@d
= none
0$ dao -e 'routine @d(f(args): routine) {io.writeln("@d")}; r=@d routine() {io.writeln("r")}; r()'
[[WARNING]] in file "command line codes":
  At line 1 : Statements not seperated properly;
[[ERROR]] in file "command line codes":
  At line 0 : Invalid function definition --- " __main__() ";
  At line 1 : Invalid virtual machine instruction --- " CALL:4,512,5 ";
In code snippet:
      4 :  LOAD        :     1 ,     0 ,     4 ;     1;   (
>>    5 :  CALL        :     4 ,   512 ,     5 ;     1;   r()
      6 :  RETURN      :     5 ,     1 ,     0 ;     1;   )
  ** Invalid number of parameter --- " too few parameters ";
     Assuming  : @routine<f:routine=>none>;
@Night-walker
Copy link

You simply mistook with the syntax:

(dao) routine @d(f(args): routine) {io.writeln("@d")}
= none
(dao) r = @d(routine() {io.writeln("r")})
= routine_17_023CBB88
(dao) r()
@d
= none

@dumblob
Copy link
Author

dumblob commented Feb 14, 2015

I did :( Thanks!

@dumblob dumblob closed this as completed Feb 14, 2015
@dumblob
Copy link
Author

dumblob commented Feb 17, 2015

Reopening, because the syntax ... r = @d routine() {... should be detected as syntax compile-time error in this case.

@dumblob dumblob reopened this Feb 17, 2015
@Night-walker
Copy link

Emm.. Isn't it what 'Statements not seperated properly' tries to say?

@dumblob
Copy link
Author

dumblob commented Feb 17, 2015

It's just warning, then the parsing successfully continues, then the code is run and first then, an error is issued:

In code snippet:
      4 :  LOAD        :     1 ,     0 ,     4 ;     1;   (
>>    5 :  CALL        :     4 ,   512 ,     5 ;     1;   r()
      6 :  RETURN      :     5 ,     1 ,     0 ;     1;   )
  ** Invalid number of parameter --- " too few parameters ";
     Assuming  : @routine<f:routine=>none>;

@Night-walker
Copy link

Oh, right.

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

No branches or pull requests

2 participants