cls definitions interacting badly with declarations

17 views
Skip to first unread message

Harvey Stein

unread,
May 17, 2015, 9:44:08 PM5/17/15
to lisp...@googlegroups.com
Consider the following function:

(defun afunction (a)
  (declare (type (simple-array  double-float (*)) a))
  a)

It compiles fine in cl-user, but if I'm in cls-user, I get:

; in: DEFUN AFUNCTION
;     (TYPE (SIMPLE-ARRAY DOUBLE-FLOAT (LISP-STAT-MATH:*)) LISP-STAT-USER::A)
;
; caught ERROR:
;   bad dimension in array type: *
;
; compilation unit finished
;   caught 1 ERROR condition

So, the lisp-stat definition of * breaks declarations that use *.

Any way to fix this?  If not, then it seriously weakens declarations and hence optimizations.

Thanks,
Harvey

A.J. Rossini

unread,
May 20, 2015, 5:18:47 AM5/20/15
to lisp-stat

Unfortunately, the best way is to not override *, but to import as needed (I can't recall, but for example ls-math::*  )? 

I am sure there are other challenges with the xls compatibility stuff, which is one of a few reasons why I (and many of the real numerics authors) prefer to use different binary operators rather than trying to have multipliciation (as an example) be overloaded. 

Of course, this is different in that the semantics are completely different.... (Wildcard vs. Math-op)

Thoughts?

Best,
-tony

--
You received this message because you are subscribed to the Google Groups "Common Lisp Statistics" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lisp-stat+...@googlegroups.com.
To post to this group, send email to lisp...@googlegroups.com.
Visit this group at http://groups.google.com/group/lisp-stat.
For more options, visit https://groups.google.com/d/optout.

Harvey Stein

unread,
May 20, 2015, 9:18:09 AM5/20/15
to lisp...@googlegroups.com
Presumably declare is looking for different symbols in specific packages and it expects * to be cl:*, so it doesn't recognize cls:*.  I fixed it by specifying cl:* instead of cls:*, which looks odd, but works.

I can't think of anything else that overriding * would cause trouble with.

I guess it could be fixed by defining a cls:declare macro that expands to cl:declare, but replaces occurrences of * with cl:*.

Thanks,
Harvey

A.J. Rossini

unread,
May 20, 2015, 11:06:48 AM5/20/15
to lisp...@googlegroups.com
If it works for you it works!  We can make 
--
Sent from }*~£%¥>%=,?

A.J. Rossini

unread,
May 20, 2015, 11:07:13 AM5/20/15
to lisp...@googlegroups.com
It prettier later.. 
Reply all
Reply to author
Forward
0 new messages