PS supports special variables but to use them requires declaring a variable with DEFVAR instead of VAR. I'm not fond of this because the DEFVAR-vs.-VAR distinction in PS doesn't fit with the DEFVAR-vs.-DEFPARAMETER distinction in CL (at least, I don't see the analogy if there is one).
What I'd like is to be able to do this:
(ps (let ((*foo* 123)) (declare (special *foo*)) (blah))) => "var FOO12733 = FOO; try { FOO = 123; blah(); } finally { FOO = FOO12733; };"
Vladimir, do you think this would be hard to do? It's similar to how LET works on variables declared with DEFVAR. The difference of course is that here *FOO* stops being a special-variable when the DECLARE goes out of scope.
Do you (or does anyone) think that the above would be a bad idea? If so, why?
We have a macro right now that does the above in a somewhat ugly way, and it's very handy on the 3 or 4 occasions that we need it.
Daniel
Do you (or does anyone) think that the above would be a bad idea? If so, why?
We have a macro right now that does the above in a somewhat ugly way, and it's very handy on the 3 or 4 occasions that we need it.
How does your macro introduce the global variable? Does it get a reference to the toplevel object? I think that's probably the way to go.
Vladimir
Daniel
parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
After scratching my head about how to get a reference to the global object for a while, StackOverflow came to the rescue:
http://stackoverflow.com/questions/383185/javascript-check-if-in-global-cont...
Implementation to be done later.
Vladimir
2010/1/4 Vladimir Sedach vsedach@gmail.com:
Do you (or does anyone) think that the above would be a bad idea? If so, why?
We have a macro right now that does the above in a somewhat ugly way, and it's very handy on the 3 or 4 occasions that we need it.
How does your macro introduce the global variable? Does it get a reference to the toplevel object? I think that's probably the way to go.
Vladimir
Daniel
parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
Cool. Do you plan to use "window" or the other trick?
To answer your earlier question - we're not accessing the global object at all; we're declaring any such variables manually using var at the toplevel (in other words, what we're doing is braindead). Stuffing them in the global object then taking them out again on scope exit seems like the right way.
Daniel
On Wed, Jan 6, 2010 at 8:03 PM, Vladimir Sedach vsedach@gmail.com wrote:
After scratching my head about how to get a reference to the global object for a while, StackOverflow came to the rescue:
http://stackoverflow.com/questions/383185/javascript-check-if-in-global-cont...
Implementation to be done later.
Vladimir
2010/1/4 Vladimir Sedach vsedach@gmail.com:
Do you (or does anyone) think that the above would be a bad idea? If so, why?
We have a macro right now that does the above in a somewhat ugly way,
and
it's very handy on the 3 or 4 occasions that we need it.
How does your macro introduce the global variable? Does it get a reference to the toplevel object? I think that's probably the way to go.
Vladimir
Daniel
parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
I actually wasn't going to delete the variables at the end of the scope - then there would have to be a flag to see if the variable was there previously and might be used by somebody.
The reason the global reference is needed is that there's no guarantee that the generated code will be executed from the toplevel, so just declaring a var wouldn't work in all contexts.
Vladimir
2010/1/6 Daniel Gackle danielgackle@gmail.com:
Cool. Do you plan to use "window" or the other trick?
To answer your earlier question - we're not accessing the global object at all; we're declaring any such variables manually using var at the toplevel (in other words, what we're doing is braindead). Stuffing them in the global object then taking them out again on scope exit seems like the right way.
Daniel
On Wed, Jan 6, 2010 at 8:03 PM, Vladimir Sedach vsedach@gmail.com wrote:
After scratching my head about how to get a reference to the global object for a while, StackOverflow came to the rescue:
http://stackoverflow.com/questions/383185/javascript-check-if-in-global-cont...
Implementation to be done later.
Vladimir
2010/1/4 Vladimir Sedach vsedach@gmail.com:
Do you (or does anyone) think that the above would be a bad idea? If so, why?
We have a macro right now that does the above in a somewhat ugly way, and it's very handy on the 3 or 4 occasions that we need it.
How does your macro introduce the global variable? Does it get a reference to the toplevel object? I think that's probably the way to go.
Vladimir
Daniel
parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
Just out of curiosity, what do Common Lisps do in this case? i.e. if a variable appears only in LET forms (not at toplevel) but is declared special in each, what happens to it when the program exits one of the scopes in which it was declared?
Daniel
On Thu, Jan 7, 2010 at 6:17 PM, Vladimir Sedach vsedach@gmail.com wrote:
I actually wasn't going to delete the variables at the end of the scope - then there would have to be a flag to see if the variable was there previously and might be used by somebody.
The reason the global reference is needed is that there's no guarantee that the generated code will be executed from the toplevel, so just declaring a var wouldn't work in all contexts.
Vladimir
2010/1/6 Daniel Gackle danielgackle@gmail.com:
Cool. Do you plan to use "window" or the other trick?
To answer your earlier question - we're not accessing the global object
at
all; we're declaring any such variables manually using var at the
toplevel
(in other words, what we're doing is braindead). Stuffing them in the
global
object then taking them out again on scope exit seems like the right way.
Daniel
On Wed, Jan 6, 2010 at 8:03 PM, Vladimir Sedach vsedach@gmail.com
wrote:
After scratching my head about how to get a reference to the global object for a while, StackOverflow came to the rescue:
http://stackoverflow.com/questions/383185/javascript-check-if-in-global-cont...
Implementation to be done later.
Vladimir
2010/1/4 Vladimir Sedach vsedach@gmail.com:
Do you (or does anyone) think that the above would be a bad idea? If so, why?
We have a macro right now that does the above in a somewhat ugly way, and it's very handy on the 3 or 4 occasions that we need it.
How does your macro introduce the global variable? Does it get a reference to the toplevel object? I think that's probably the way to go.
Vladimir
Daniel
parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
I just pushed a patch that handles SPECIAL declarations in functions and LET forms. I don't know why I thought I needed a reference to the global object though. There's no need to declare globals.
Vladimir
2009/12/30 Daniel Gackle danielgackle@gmail.com:
PS supports special variables but to use them requires declaring a variable with DEFVAR instead of VAR. I'm not fond of this because the DEFVAR-vs.-VAR distinction in PS doesn't fit with the DEFVAR-vs.-DEFPARAMETER distinction in CL (at least, I don't see the analogy if there is one).
What I'd like is to be able to do this:
(ps (let ((*foo* 123)) (declare (special *foo*)) (blah))) => "var FOO12733 = FOO; try { FOO = 123; blah(); } finally { FOO = FOO12733; };"
Vladimir, do you think this would be hard to do? It's similar to how LET works on variables declared with DEFVAR. The difference of course is that here *FOO* stops being a special-variable when the DECLARE goes out of scope.
Do you (or does anyone) think that the above would be a bad idea? If so, why?
We have a macro right now that does the above in a somewhat ugly way, and it's very handy on the 3 or 4 occasions that we need it.
Daniel
parenscript-devel mailing list parenscript-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-devel
parenscript-devel@common-lisp.net