This is the mail archive of the kawa@sourceware.org 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: GSOC | Extending Common Lisp support


* Jamison Hope [2012-06-25 20:15] writes:
> Looks like setq#rewriteForm needs to have a tr.rewrite(name) in there
> to get
> a ReferenceExp the way set_b#rewriteForm does.

This seems to work:

	Declaration decl = tr.lookup(name, Language.VALUE_NAMESPACE);
	SetExp sexp = (decl == null 
		       ? new SetExp(name, value) 
		       : new SetExp(decl, value));
	if (decl != null) {
	    decl.noteValueFromSet(sexp);
	}

Why noteValueFromSet is needed is a mystery to me.

> On a side note:
> I'm a little puzzled by why setq will accept a String as the variable,
> and why it explicitly uses the String "nil" as the variable if it sees
> CommonLisp.FALSE (i.e. nil). Both of these expressions seem like they
> should be errors (and in fact *are* errors in SBCL):
> (setq "hello" "world")
> (setq nil 5)
> Some brief svn log spelunking seems to indicate that it's been that way
> for a very long time.

Long ago, Kawa used (interned) Strings to represent symbols.  This is
probably a left over from that time.

[...]
> Another option right now (yes, a total hack) would be to do something
> like
> this:
>
> (defun f (x y &key (test 'test-default) (test-not 'test-not-default))
>   (when (and (not (eq test 'test-default))
>              (not (eq test-not 'test-not-default)))
>         (error "can't supply both"))
>   (when (eq test 'test-default) (setq test #'eql))
>   (when (eq test-not 'test-not-default) (setq test-not nil))
>   ...)
>
> i.e. choose default values that are only meaningful as default tokens,
> not as the actual defaults you intend to use.

&rest args can be used to (inefficiently) emulate keyword args.  E.g.

(defun f (x y &rest rest)
  (let* ((test-supplied-p (member ':test rest))
         (test (if test-supplied-p (cadr test-supplied) #'eql))
         (test-not-supplied-p  (member ':test-not rest)))
      ... ))

If member isn't working use your own memq.  This could also be packed up
as a macro like, uh:

  (destructuring-bind (&key (test #'eql test-supplied-p)) rest
       ...


>> I also noticed a weird bit of behaviour (noticed whilst puzzling over
>> why my PUSH wasn't working):
>>
>> #|kawa:4|# '(1 . ())
>> (1)
>> #|kawa:5|# '(1 . nil)
>> (1 . nil)
>> #|kawa:6|# (eq '() nil)
>> t
>
> I think that one is because (quote nil) is not currently evaluating to
> nil, as it should:

I think this is a reader issue: (eq 'nil '()) => #f

Helmut


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