On Jun 19, 2010, at 1:05 PM, Tim Daly wrote:


(proclaim (speed 3) (safety 0))

is verbose? Telling the compiler in one place that you care
about boxing speed, such as (declare (x unboxed)) seems to
me to be a very direct way to tell the compiler to choose
+' vs + everywhere that 'x' occurs.

This means that "it just works" code does not need additional
unboxing overhead. It also means that "make it fast" code is
marked in a single place.

And the form can be dynamically computed so you can adapt to
the platform.

It has the additional factor that common lispers will "get it".

I understand that it does not fit with your current model of
using inline typing. For a pervasive change like fast numerics
the inline typing or library-based typing is, to my mind, a bit
more cumbersome than 'proclaim' and 'declare' but that's probably
because of my common lisp background. Type hinting feels to me
like using symbol-property machinery in common lisp.


I don't want to get into it here, but the CL model in this area is quite cumbersome and opaque, IMO.

What precisely will (proclaim (speed 3) (safety 0)) do?

And of course, that is never enough, this from the CL spec:

(defun often-used-subroutine (x y)
  (declare (optimize (safety 2)))
  (error-check x y)
  (hairy-setup x)
  (do ((i 0 (+ i 1))
       (z x (cdr z)))
      ((null z))
      ;; This inner loop really needs to burn.
      (declare (optimize speed))
      (declare (fixnum i))
      ))

The (declare (fixnum i)) above being pertinent to this discussion vis- a-vis verbosity.

Not to mention the wonderful 'the' (this also from the CL spec):

(let ((i 100)) (declare (fixnum i)) (the fixnum (1+ i))) => 101

N.B. that the declaration of the type of i does not cover the result of 1+, which needs its own declaration.

Never mind that trading runtime safety for speed is completely not on the table for Clojure. It is one of the great lies of CL that it is both safe and very fast. It is safe *or* very fast. Clojure code will remain verifiable and safe.

The CL model is not something I want to emulate in Clojure.

Point taken about the type hinting. OTOH, metadata type hints flow through macros, whereas the decoupled i and its declaration of the CL above are extremely difficult to transform together. Metadata flowing is really an enormous win, IMO.

Rich

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to