News for hackers. Stuff that matters.
Re:A new version of Common-Lisp.net has been launched by lispm on Thursday October 11, 2018 @09:44AM (#18193447)
Many CL implementations have a type inferencer (usually so that the compiler can optimize code without the developer having to specify types everywhere). What sets SBCL (and CMUCL and Scieneer CL) apart is that it does limited forms of compile time type checking:

http://www.sbcl.org/manual/index.html#Handling-of-Types

Re:A new version of Common-Lisp.net has been launched by lisper on Thursday October 11, 2018 @10:07AM (#18193636)
> type inferencer

> compile time type checking

Aren't those the same thing?

Re:A new version of Common-Lisp.net has been launched by lispm on Thursday October 11, 2018 @10:21AM (#18193743)
No. A type inference does not check types. It inferences types.

For example if you know that + is defined for numbers, then you can inference that a and b must be numbers: (+ a b)

If you know that a and b are numbers then you can inference that subexpressions need to deal with numbers only:

   (let ((a c) (b d)) (declare (type number a b)) ....)
The type inferencer then will tell what types the various expressions have. It will try to propagate known types as widely as possible in the code.

Allegro CL and LispWorks for example are doing this type inference. But their compiler will not tell you that type declarations are violated.

SBCL OTOH treats type declarations as type assertions which can be checked at compile time. ADDITIONALLY it also does type inference - and additionally uses this information for compile time type checks.

Re:A new version of Common-Lisp.net has been launched by lisper on Thursday October 11, 2018 @11:51AM (#18194519)
> A type inference does not check types. It inferences types.

OK, on that definition, of what possible use is a type inferencer? Aren't they useful only as a component of a compile-time type checker?

Re:A new version of Common-Lisp.net has been launched by lispm on Thursday October 11, 2018 @12:25PM (#18194839)
Convenience.

Basically CCL's compiled code is often as fast as code from SBCL, LispWorks, Allegro CL. But one has to declare much more types of variables and functions explicitly with CCL. The code needs to be littered with type declarations.

A compiler with a (better) type inferencer can propagate the type information it already has and this is often enough for fast code. A good compiler can then also tell the developer where it lacks type information and then you can decide to declare types explicitly. SBCL/CMUCL does that in a very noisy way with lots of information generated by the compiler. ;-)

See for example: http://home.pipeline.com/~hbaker1/TInference.html

Re:A new version of Common-Lisp.net has been launched by ken on Thursday October 11, 2018 @12:34PM (#18194913)
Performance. If you have (+ x y) and you can infer that x and y are fixints, then you can use a couple inline opcodes, rather than calling GENERIC-+.

EDIT: lispm is right, too, of course. You can look at it either way. If your program required top performance and you were going to tag every type until it ran super fast, then inference buys you the convenience of not needing to do as much. If you weren't going to bother with that, then inference buys you extra performance without all the effort.

Re:A new version of Common-Lisp.net has been launched by JasonFruit on Thursday October 11, 2018 @11:07AM (#18194101)
('Infer' is a perfectly good verb; you don't have to make one out of 'inference'. But sometimes it's easy to disremembrance things like that on HN.)
Re:A new version of Common-Lisp.net has been launched by lisper on Thursday October 11, 2018 @11:52AM (#18194525)
I believe lispm is not a native English speaker. His website TLD is .de.
Re:A new version of Common-Lisp.net has been launched by JasonFruit on Thursday October 11, 2018 @01:17PM (#18195271)
Yes, I see. Doesn't mean he or she might not rather be correct, however.
Re:A new version of Common-Lisp.net has been launched by lisper on Thursday October 11, 2018 @01:21PM (#18195306)
True that.
Re:A new version of Common-Lisp.net has been launched by lispm on Thursday October 11, 2018 @12:21PM (#18194805)
Thanks, didn't remember that.
Re:A new version of Common-Lisp.net has been launched by mercer on Thursday October 11, 2018 @12:40PM (#18194958)
It's an easy mistake to make. Incidentally, "infer", for some reason, is a word I find unusually pleasing.

EDIT: as a non-native speaker I distinctly remember first reading the word and happily using it ever since, when appropriate.

Re:A new version of Common-Lisp.net has been launched by vram22 on Thursday October 11, 2018 @01:52PM (#18195605)
And a similar possibly wrong usage is "conference" when used as a verb, maybe, since "confer" is probably okay. But "conference" seems to have become accepted, I've heard it a bit. There's this trend (from many years, not just recent) to make nouns into verbs too, e.g. "Skype me". The "confer" form as a verb probably sounds archaic to many, since it's not commonly heard or read (AFAIK).
Re:A new version of Common-Lisp.net has been launched by JasonFruit on Thursday October 11, 2018 @01:14PM (#18195251)
Perfectly fair — I'm sure you're not the first to inference something. And yes, 'infer' is an interesting word, especially when you bring in Latin.
Re:A new version of Common-Lisp.net has been launched by eslaught on Thursday October 11, 2018 @01:19PM (#18195292)
> SBCL OTOH treats type declarations as type assertions which can be checked at compile time.

Wait, is that really not the standard behavior?

Re:A new version of Common-Lisp.net has been launched by lispm on Thursday October 11, 2018 @01:32PM (#18195417)
CMUCL invented that in the mid/end 80s. CMUCL forks like SBCL and Scieneer CL got it there. The other compilers don't do that.
Re:A new version of Common-Lisp.net has been launched by omaranto on Thursday October 11, 2018 @10:21AM (#18193738)
I don't think so. A type inferencer figures out types of expressions that don't have a type explicitly declared using information it has about other things that are declared.

A compile time type checker is expected to signal errors at compile time for programs whose types don't check out.

You can use a type inferencer without signaling any errors at compile time (for example, by deferring errors to runtime) and you can signal type errors at compile time even if you don't infer any types (like C compilers, that demand all variables have a declared type).