chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-hackers] Whishlist entry: macro expansion for type declarations


From: Jörg F . Wittenberger
Subject: [Chicken-hackers] Whishlist entry: macro expansion for type declarations.
Date: 25 Feb 2013 21:18:20 +0100

Hi all,

maybe that's not a wishlist entry, but just me missing somthing?

When adding type declarations to some source, which has grown
for over a decade, I ran into this situation:

There's are widespread use cases of some types, which are actually
implemented as vectors, pairs or lists with a certain substructure.

The original idea to add types to this otherwise working (and relied
upon) program was to simplify the structure.  Thus I don't just want
to add the "type as is happens to be" using a long wielded construct
like

   (or boolean (pair (struct whatever) (pair symbol maybesomthing)))

which would be what I'd have to write next dozends of times.
Once I'd be through this, I'd like to replace the "(pair ...)" stuff
and selectively remove the "boolean" alternative.

This is so error-prone that I don't dare!

My "great idea" was, to write a handful of templates using
define-syntax and then use these where appropriate.  This would
allow me to change these as desired and then fix all the resulting
warnings ((second wishlist entry: have a compiler switch to turn
these warnings into errors)) accordingly.

So I wrote

(define-syntax :foo-type-or-not:
 (syntax-rules ()
((_) (or boolean (pair (struct whatever) (pair symbol maybesomthing))))))

and used it like this

(: bar (my params -> (:foo-type-or-not:)))

But: chicken complains that the (:foo-type-or-not:) macro I defined
would be illegal in the type annotation.

I take this as sign that the macro was not expanded at all.

Correct?  Any way to get this done?  If not, would it be feasible to
add this expansion step into chicken?

Thanks a lot!

/Jerry



............




reply via email to

[Prev in Thread] Current Thread [Next in Thread]