> A language extension means the syntax wouldn't ever be valid in the base language.
Sure.
(struct pt ([x : Real] [y : Real]))
That's not valid Racket, but is valid Typed Racket.A more extreme example:
int main(int argc, char** argv) { return 0; }
That's C! Oh wait, it's the C #lang [0]...Which means you can things like:
base.rkt:
#lang C
float f( float x1, float x2 ) {
return x1 / x2;
}
main.rkt: #lang racket
(require base)
f(10.2, 1.8)
Those syntaxes aren't compatible, by any stretch. The magic is, Racket gives you access to powerful pre-processing, in the form of some amazing reader macros.What syntax you use, doesn't really matter, so long as you provide that bridge. They're incompatible syntax, with a custom made parser allowing data to flow both ways.
(f 10.2 1.8)In the case of the implementation I listed, it passes it on literally, and compiles it and runs it, and then takes the output and passes it back to Racket. [0]
[0] https://github.com/jeapostrophe/c/blob/master/c/lang/runtime...
Or maybe I wasn't clear. If Scheme tries to pass a double/bignum/whatever to the C function that expects the float, where is the error caught?
In this case, it's just throwing strings around without changing anything. No passing to transform a bignum, no bounds checking. Just tries to run it. (Racket does have a decent FFI [0], but this library is just for classroom example stuff. Not serious work.)
The langue "racket" is implemented in "racket/base" that is implemented in "pre-base" that is implemented in #%kernel. If you want to use `for` you must use "racket" or "racket/base" or "pre-base", because it isn't defined in #%kernel. If you want to use `match` you must use "racket" because it isn't defined in the other three languages.
The language "#%kernel" has a minimal syntaxes defined, so it's painful to use.
Well, this works:
#lang base-without-for
(require the-for-library)
...use for here...
Of course if the author of `for` has made a `base-with-for` language, then I can just use: #lang base-with-for
...use for here...
I don't buy it.
A language extension means the syntax wouldn't ever be valid in the base language. The fact that Racket defines its 'for' construct using macros/functions/whatever is cute, but I see no reason to pretend it's a language extension.