You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice to have a macros (e. g. cdefun) like define-route, but defining a generic function, which takes an additional argument - the submodule-designated symbol. Each mount-submodule also generate methods for those function, specialized for the symbol, specified in it. Those methods will just put the code of the function into the submodule context, with all dynamically scoped variables will seem like the function is called from a route of this submodule. For example:
; mod1:
(defvar *var* 0)
(cdefun add-var (a) (+ *var* x) ) ; <-- the function here depend on dynamically scoped context
; mod2:
(mount-submodule sm1 (#:mod1) ; <-- Create two different contexts
(mod1:*var* 1)) ; /
(mount-submodule sm2 (#:mod1) ; <-
(mod1:*var* 2))
; Call function in different contexts
(mod1:add-var 'sm1 1) ;--> 2
(mod1:add-var 'sm2 1) ;--> 3
And it still handles restas:genurl improperly (relative to the current module, not to the 'sm1).
It's just a proposal, may be there is a more elegant solution.
The text was updated successfully, but these errors were encountered:
It would be nice to have a macros (e. g. cdefun) like define-route, but defining a generic function, which takes an additional argument - the submodule-designated symbol. Each mount-submodule also generate methods for those function, specialized for the symbol, specified in it. Those methods will just put the code of the function into the submodule context, with all dynamically scoped variables will seem like the function is called from a route of this submodule. For example:
; mod1:
; mod2:
;mod3:
Here the first invocation and the third will refer to the different methods, because the symbols mod2:sm1 and mos3:sm1 are different.
I know one way to achieve such results now -- using the restas:with-context macro. But it is quite verbose (and undocumented, as far as I know):
And it still handles restas:genurl improperly (relative to the current module, not to the 'sm1).
It's just a proposal, may be there is a more elegant solution.
The text was updated successfully, but these errors were encountered: