unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Meaning of <=> in the context of procedures
@ 2021-06-02 14:06 Mortimer Cladwell
  2021-06-02 16:12 ` Linus Björnstam
  2021-08-04 11:55 ` Ludovic Courtès
  0 siblings, 2 replies; 4+ messages in thread
From: Mortimer Cladwell @ 2021-06-02 14:06 UTC (permalink / raw)
  To: guile-user

Hi,
What does <=> mean/do?
It can be found in guile-json in the (json record) module, line 33:

33 #:export (<=> define-json-mapping define-json-type))

Not mentioned in the entire Guile manual. Happens to be defined on line 36
of the module:

36  (define <=> '<=>)

I didn't find that very helpful :)
Thanks
Mortimer


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Meaning of <=> in the context of procedures
  2021-06-02 14:06 Meaning of <=> in the context of procedures Mortimer Cladwell
@ 2021-06-02 16:12 ` Linus Björnstam
  2021-06-02 16:21   ` Linus Björnstam
  2021-08-04 11:55 ` Ludovic Courtès
  1 sibling, 1 reply; 4+ messages in thread
From: Linus Björnstam @ 2021-06-02 16:12 UTC (permalink / raw)
  To: Mortimer Cladwell, guile-user

It is a trick to allow using the symbol '<=> as an identifier instead of quoting it. Nothing special. Guile-json probably uses it somehow.

If it is used as auxiliary syntax in a macro, it is probably exported so guile can warn that it is being shadowed instead of (or rather: in addition to) producing bad error messages.

-- 
  Linus Björnstam

On Wed, 2 Jun 2021, at 16:06, Mortimer Cladwell wrote:
> Hi,
> What does <=> mean/do?
> It can be found in guile-json in the (json record) module, line 33:
> 
> 33 #:export (<=> define-json-mapping define-json-type))
> 
> Not mentioned in the entire Guile manual. Happens to be defined on line 36
> of the module:
> 
> 36  (define <=> '<=>)
> 
> I didn't find that very helpful :)
> Thanks
> Mortimer
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Meaning of <=> in the context of procedures
  2021-06-02 16:12 ` Linus Björnstam
@ 2021-06-02 16:21   ` Linus Björnstam
  0 siblings, 0 replies; 4+ messages in thread
From: Linus Björnstam @ 2021-06-02 16:21 UTC (permalink / raw)
  To: Mortimer Cladwell, guile-user

To reply to myself: it is an exported identifier that is used in a define-json-mapping. It is good form for macros to export all its auxiliary syntax. 


-- 
  Linus Björnstam

On Wed, 2 Jun 2021, at 18:12, Linus Björnstam wrote:
> It is a trick to allow using the symbol '<=> as an identifier instead 
> of quoting it. Nothing special. Guile-json probably uses it somehow.
> 
> If it is used as auxiliary syntax in a macro, it is probably exported 
> so guile can warn that it is being shadowed instead of (or rather: in 
> addition to) producing bad error messages.
> 
> -- 
>   Linus Björnstam
> 
> On Wed, 2 Jun 2021, at 16:06, Mortimer Cladwell wrote:
> > Hi,
> > What does <=> mean/do?
> > It can be found in guile-json in the (json record) module, line 33:
> > 
> > 33 #:export (<=> define-json-mapping define-json-type))
> > 
> > Not mentioned in the entire Guile manual. Happens to be defined on line 36
> > of the module:
> > 
> > 36  (define <=> '<=>)
> > 
> > I didn't find that very helpful :)
> > Thanks
> > Mortimer
> > 
> 
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Meaning of <=> in the context of procedures
  2021-06-02 14:06 Meaning of <=> in the context of procedures Mortimer Cladwell
  2021-06-02 16:12 ` Linus Björnstam
@ 2021-08-04 11:55 ` Ludovic Courtès
  1 sibling, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2021-08-04 11:55 UTC (permalink / raw)
  To: guile-user

Hi Mortimer,

Mortimer Cladwell <mbcladwell@gmail.com> skribis:

> What does <=> mean/do?
> It can be found in guile-json in the (json record) module, line 33:
>
> 33 #:export (<=> define-json-mapping define-json-type))
>
> Not mentioned in the entire Guile manual. Happens to be defined on line 36
> of the module:
>
> 36  (define <=> '<=>)

I’m very late, but in short, ‘<=>’ is used a “syntactic keyword” in the
‘define-json-type’ macro (IOW, it’s among the “literals” of
‘syntax-rules’).

“Good practice” these days is that syntactic keywords should be bound.
This ‘define’ does just that: binding ‘<=>’.  Its actual value doesn’t
matter.

The advantage of that is that you can renaming bindings (with #:prefix
for instance), you can see when two syntactic bindings clash, and so on.

Quoth the manual (info "(guile) Syntax Rules"):

     A literal matches an input expression if the input expression is an
  identifier with the same name as the literal, and both are unbound(1).

     Although literals can be unbound, usually they are bound to allow
  them to be imported, exported, and renamed.  *Note Modules::, for more
  information on imports and exports.  In Guile there are a few standard
  auxiliary syntax definitions, as specified by R6RS and R7RS:

   -- Scheme Syntax: =>
   -- Scheme Syntax: _
   -- Scheme Syntax: ...
       Auxiliary syntax definitions.

       These are defined as if with a macro that never matches, e.g.:

            (define-syntax else (syntax-rules ()))

HTH!

Ludo’.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-08-04 11:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-02 14:06 Meaning of <=> in the context of procedures Mortimer Cladwell
2021-06-02 16:12 ` Linus Björnstam
2021-06-02 16:21   ` Linus Björnstam
2021-08-04 11:55 ` Ludovic Courtès

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).