Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

in search of a cute type predicate syntax

20 views
Skip to first unread message

Marco Maggi

unread,
May 13, 2012, 4:51:55 AM5/13/12
to
Ciao,

I am redesigning the class libraries in Nausicaa[1]; one goal
is to allow use of classes and labels by importing only the type
identifier (which is a macro keyword) and not the full language
(nausicaa). For example:

#!r6rs
(library (alpha)
(export <alpha>)
(import (nausicaa))
(define-class <alpha>
---))

#!r6rs
(import (rnrs)
(alpha))
--- ;;build and use instances of <alpha>

To this end, the following syntax:

(<alpha> a ?expr)

expands to:

(define G0 ?expr)
(define-syntax a
(make-appropriate-transformer #'G0))

and the following syntax:

(<alpha> (?arg ...))

expands to (more or less):

(make-<alpha> ?arg ...)

What I miss is a nice syntax for the predicate "is OBJ of type
<alpha>?"; that is a syntax:

(--- <alpha> --- ?expr ---)

that expands to:

(<alpha>? ?expr)

whenever the full language (nausicaa) is imported, I can use:

(is-a? ?expr <alpha>)

and using only the type identifier I can do:

(<alpha> :is-a? ?expr)

but I am not satisfied with the latter: it is not cute enough.
;-) I am considering:

((<alpha>) ?expr)

are these syntaxes too confusing?

TIA

[1] <http://marcomaggi.github.com/docs/nausicaa.html/classes.html>
--
Marco Maggi
0 new messages