Re: Question about how to check a symbol is bound

2023-06-29 Thread Peter Bex
On Wed, Jun 28, 2023 at 09:32:36PM +0200, felix.winkelm...@bevuta.com wrote: > But I still think that keeping an expansion/compile-time registry and > accessing it using procedure macros (via "strip-syntax"ed identifiers > to drop all renaming artifacts) is a possible solution. I agree, that's

Re: Question about how to check a symbol is bound

2023-06-28 Thread felix . winkelmann
> On 28/06/2023 14:09, felix.winkelm...@bevuta.com wrote: > >> > >> (define-object-type bar > >> (field-1 name-of-library#foo) > >> (field-2 name-of-other-library#some-other-type)) > >> > >> ...even though calling symbol-value on those symbols at run time works > >> just fine. It seems

Re: Question about how to check a symbol is bound

2023-06-28 Thread Alaric Snell-Pym
On 28/06/2023 14:09, felix.winkelm...@bevuta.com wrote: I guess during expansion identifiers are renamed to some internal gensym and thus not accessible by name (which is the whole point of a hygienic macro system). Oh, and as a side thing, I don't think this is exactly "unhygienic". Well,

Re: Question about how to check a symbol is bound

2023-06-28 Thread Alaric Snell-Pym
On 28/06/2023 14:09, felix.winkelm...@bevuta.com wrote: (define-object-type bar (field-1 name-of-library#foo) (field-2 name-of-other-library#some-other-type)) ...even though calling symbol-value on those symbols at run time works just fine. It seems that the symbols imported into the

Re: Question about how to check a symbol is bound

2023-06-28 Thread felix . winkelmann
> > (define-object-type bar >(field-1 name-of-library#foo) >(field-2 name-of-other-library#some-other-type)) > > ...even though calling symbol-value on those symbols at run time works > just fine. It seems that the symbols imported into the environment at > macro expansion time are handled

Re: Question about how to check a symbol is bound

2023-06-28 Thread Alaric Snell-Pym
On 23/06/2023 14:35, Kon Lovett wrote: (symbol-value foo #f) Error: unbound variable: foo #;2> (symbol-value 'foo #f) #f (symbol-value foo #f) is asking for the symbol-value of the derefed variable `foo’ Does anybody have any tips for using symbol-value at macroexpansion time? I am trying

Re: Question about how to check a symbol is bound

2023-06-23 Thread Kon Lovett
> On Jun 22, 2023, at 9:07 PM, Pan Xie wrote: > > Hello > > I am new to CHICKEN scheme and here is a (very) quick question of how to > check whether a symbol is bound. > > I know it doable but I can't find the way. > > I don't find the methods from the main CHICKEN manual document. Then I

Re: Question about how to check a symbol is bound

2023-06-23 Thread Thomas Chust
Hello, if you are looking for record introspection capabilities, I would recommend looking into SRFI-99[1], which combines static structure definition and dynamic reflection APIs. You're example could look like this: (import (chicken format) srfi-42 srfi-99) (define-record-type egg-info

Re: Question about how to check a symbol is bound

2023-06-23 Thread Peter Bex
On Fri, Jun 23, 2023 at 04:01:40PM +0800, Pan Xie wrote: > For example, if I want to do things shown in following codes, it is useful to > get the > interned symbols from their names and also get their bound procedures: ...[code elided]... > I think it is a very common idiom in languages from

Re: Question about how to check a symbol is bound

2023-06-23 Thread Lassi Kortela
 (define-record egg-info    name author desc)  (define (show-egg-info egg)    (define (symbol-value sym) (##sys#slot sym 0))    (define (getter field-name) (symbol-value   (string->symbol    (format #f "egg-info-~a"    field-name    (let ((fields

Re: Question about how to check a symbol is bound

2023-06-23 Thread Pan Xie
#+begin_quote Perhaps if you can explain why you need to know if a symbol is bound or unbound, we might be able to help you better achieve your goal. #+end_quote For example, if I want to do things shown in following codes, it is useful to get the interned symbols from their names and also get

Re: Question about how to check a symbol is bound

2023-06-23 Thread Peter Bex
On Fri, Jun 23, 2023 at 03:32:38PM +0800, Pan wrote: > Ah, that make sense. It seems I can just use the '##sys#slot' procedure to > accomplish all that tasks. Please don't use ##sys#slot unless you know what you're doing - the procedure is unsafe and will cause segmentation faults when used on

Re: Question about how to check a symbol is bound

2023-06-23 Thread Pan
Ah, that make sense. It seems I can just use the '##sys#slot' procedure to accomplish all that tasks. Would you please elaborate about the "transformed name"? I see there are codes reference symbols like "##sys#slot" or "scheme#list", but I can't find document describe them. Is there any

Re: Question about how to check a symbol is bound

2023-06-22 Thread Shawn Wagner
Looks like unbound? and symbol-value take quoted symbols if passing them directly: And for list you have to use the transformed name scheme#list #;2> (unbound? 'x) #t #;3> (define x 1) #;4> (unbound? 'x) #f #;5> (symbol-value 'x) 1 #;6> (symbol-value 'scheme#list) # On Thu, Jun 22, 2023 at 10:15 

Question about how to check a symbol is bound

2023-06-22 Thread Pan Xie
Hello I am new to CHICKEN scheme and here is a (very) quick question of how to check whether a symbol is bound. I know it doable but I can't find the way. I don't find the methods from the main CHICKEN manual document. Then I import the "symbol-value-utils" module. I believe the "unbound?"