[plt-scheme] keywords aren't isomorfic to symbols?

From: Hans Oesterholt (hdnews at gawab.com)
Date: Sun Nov 6 18:36:01 EST 2005

So I misinterpreted by assuming the use of keywords was closer to
the use of symbols than to e.g. the use of strings?

What does this mean for the use of keywords from 'inside mzscheme'?

Thanks for the answers anyway. I'll need to modify more code
then I assumed first to let keywords work for 'named arguments'.

Best whishes,

Hans

Eli Barzilay schreef:

>On Nov  6, Hans Oesterholt wrote:
>  
>
>>Hi,
>>
>>The original mail about keywords states:
>>
>>    
>>
>>>/ * Syntactic forms can also use keywords, and pattern matching "just
>>>      
>>>
>>/>/   works". Using keywords can help clarify when a syntactic form
>>/>/   expects to match literals (e.g., the colon in a `compound-unit/sig'
>>/>/   form) versus bindings (e.g., `quasiquote' in a `match' pattern).
>>
>>So why doesn't the following work?
>>    
>>
>
>Keywords are like *symbols* not like identifiers.
>
>
>  
>
>>*******************************************************************************
>>Welcome to MzScheme version 299.403, Copyright (c) 2004-2005 PLT Scheme, Inc.
>>    
>>
>>(define-syntax a
>>  (syntax-rules ()
>>    ((_ b ...)
>>     (list 'b ...)
>>     )))
>>
>>(define q (a e f g h i j))
>>(map (lambda (x) (symbol? x)) q)
>>    
>>
>>>>(#t #t #t #t #t #t)
>>>>        
>>>>
>>>(define-syntax ka
>>>      
>>>
>>  (syntax-rules ()
>>    ((_ kb ...)
>>     (list #:kb ...)
>>     )))
>>    
>>
>
>There is no connection between the input `kb' and the output `#:kb'.
>The "#:" part is not like "'" -- there is no form holding a `kb'
>identifier like in 'kb.  To see how this doesn't work, consider how
>this breaks:
>
>  (define-syntax ka
>    (syntax-rules ()
>      ((_ kb ...)
>       (list "kb" ...))))
>
>This might make more sense:
>
>  (define-syntax ka
>    (syntax-rules ()
>      ((_ #:kb ...)
>       (list #:kb ...))))
>
>but it fails because `#:kb' is not a pattern variable, just like
>
>  (define-syntax ka
>    (syntax-rules ()
>      ((_ "kb" ...)
>       (list "kb" ...))))
>
>  
>



Posted on the users mailing list.