On 19.09.2021 09:54, Damien Mattei wrote: > hello, > i'm developing an extension to Scheme > and i need a procedure or macro that define a variable only if it is not bind > and if it is just set! it. > > I can not do it in Guile or any Scheme,and i'm desperately searching a way to > do that. I finally conclude that it can be done only by adding it in the > language. > > Can someone include a such function in Guile next release? > i know guile have a predicate defined? to test binfing of a vairable but > writing a macro with it is not possible because define can be used in an > expression context. > > Thank in advance for any help > Damien
What is the utility of such a function? Since Scheme is lexically scoped, it's generally obvious whether a variable has already been defined or not, rendering such an operation useless. If you're constructing code from outside input so that you don't know whether a provided variable name represents a variable that's already been defined or not, then you could use the module reflection API: https://www.gnu.org/software/guile/manual/html_node/Module-System-Reflection.html Sounds like 'module-define!' does exactly what you ask for. I wonder what exactly your use-case is though. Chances are that your use-case is best served with a simple data structure like a hash table... -- Taylan