Hi there,

On 2017-03-16 17:22, megane wrote:
> Currently symbol->string strips any keyword prefixes when applied to
> keywords (e.g. (symbol->string 'foo:) returns "foo"). Is this correct
> behavior?

That's the correct behaviour, yes. symbol->string basically ignores
keywords and treats them just like normal symbols in this regard.

> Is there a way to get the full symbol name (i.e. #:foo -> "#:foo", and
> foo: -> "foo:")?

Not really. #:foo and foo: are both textual representations of the same
symbol. The "style" of the keyword isn't kept around after it's read, so
all the runtime knows is that (a) there's a symbol "foo" and (b) it's a
keyword. It's not specifically a "prefix" or "suffix" keyword until
written out again.

Anyway, to get a string that *looks* like a keyword, the easiest option
is probably to go via the written representation with something like:

   (format "~s" foo:)

However note that this is sensitive to the keyword-style parameter, as
hinted at above:

   (parameterize ((keyword-style #:prefix)) (format "~s" #:foo)) ; => ":foo"
   (parameterize ((keyword-style #:suffix)) (format "~s" #:foo)) ; => "foo:"
   (parameterize ((keyword-style #f))       (format "~s" #:foo)) ; => "#:foo"

Hope that helps,

Evan

_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to