Nim Nuggets: Nim talk at Strange Loop 2021

jfondren julian.fondren at
Sun Oct 17 23:49:05 UTC 2021

On Sunday, 17 October 2021 at 21:17:43 UTC, Paulo Pinto wrote:
> The very first compiler for Lisp was created in 1960 for the 
> IBM 704.
> Common Lisp was just one example among others, here are a few 
> more.
> - Dylan, released to the public in 1995

AKA, Common Lisp.

> - Template Haskell, initially prototyped in 2002

I don't know of your other examples, but Common Lisp and Template 
Haskell are in the category with C++ templates of "this could be 
technically abused towards compile time evaluation (which still 
isn't ctfe) if someone wanted to, but people generally didn't 
because it didn't occur to them".

I gave an example of a trivial macro earlier. It's from , where it's preceded by

(defun sleep-units% (value unit)
     (* value
        (case unit
          ((s) 1)
          ((m) 60)
          ((h) 3600)
          ((d) 86400)
          ((ms) 1/1000)
          ((us) 1/1000000)))))

A normal function. Which was not simply used at compile-time; 
instead, a macro version was written so that the same calculation 
could occur at compile-time. And this is what people'd tend to do 
in Common Lisp. The function actually could be used at 
compile-time but the EVAL-WHEN syntax to do that is so heavy, 
nobody would bother without ctfe having occurred to them.

An example of a language where people genuinely did write normal 
functions and then freely execute them at compile-time is Forth, 
and there the community mostly bemoaned that poor optimizers made 
it necessary to use even for constant-folding:

: rotchar ( c -- c' )
   dup  [char] a [ char m 1+ ] literal within 13 and
   over [char] A [ char M 1+ ] literal within 13 and +
   over [char] n [ char z 1+ ] literal within -13 and +
   over [char] N [ char Z 1+ ] literal within -13 and + + ;

WITHIN checks a half-open range, so it's getting passed 'a' and 
'z'+1, with compile-time calculation of the latter happening due 
to `[ ... ] literal`

When a better optimizer is available you'd just write `'a' 'z' 1+ 

> It is useless for the community to whine who did it first, 
> because it won't increase its audience.

This is a really strange axe to grind.

More information about the Digitalmars-d mailing list