This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Diagnosing macros; testing for <type>


Jocelyn Paine wrote:
> Does Kawa provide a way to see the results of a macro expansion? I'm
> getting unexpected results from the expansion of one of my
> define-syntax's, and want to find out what Kawa thinks it's expanding to.

It might be useful, but it is difficult for syntax-rules macros, since
the is tied into name lookup (because of the name hygiene).  If other
Scheme's have useful macros debugging facilities that work with
syntax-rules macros, perhaps we coudl add them.

Until then, what you can do is look at the sources for SyntaxRule and
SyntaxRules and enable various debugging print-outs that are normally
commented out.

> Also, in a macro (or indeed anywhere else), is there a built-in to test
> whether a symbol is a type specifier such as <int> or <java.util.Vector>?
> Or do I just have to look to see whether it begins with "<" and ends with
> ">"?

First <int> is a normal and valid Scheme symbol.  Conceptually a
type specifier is just an identifier that is bound to a type value.
What kawa does (or at least is supposed to) is only look for a type
only if the symbol is otherwise unbound.  There are some contexts
where it know the value must be a type value, so it resolves it at
compile time.  This is not always as clean as it should be!

#|kawa:1|# <java.lang.String>
ClassType java.lang.String
#|kawa:3|# (define <java.lang.String> 99)
#|kawa:4|# <java.lang.String>
99

I'd like to alow more complex "type expressions" though there are
some issues there I'm not quite sure about!

So basically if you need to determine whether some is or is not a
type, don't.  Make it clear from the syntax, the way many Kawa
builtins use '::'.
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/per/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]