106 karma · joined Aug 22, 2014 (12y ago) · 32 submissions
comment 8y ago · link · parent
comment 9y ago · link · parent
comment 9y ago · link · parent
comment 9y ago · link · parent
comment 9y ago · link · parent
11.
Firefox: Project Quantum(medium.com ↗)
2 points · by chaoky · 10y ago · discuss
comment 10y ago · link · parent
comment 10y ago · link · parent
comment 11y ago · link · parent
comment 11y ago · link · parent
comment 11y ago · link · parent
If this author's definition of "does not work" means that they can't be used to build operating systems or high level AI programs well...
comment 11y ago · link · parent
comment 11y ago · link · parent
comment 11y ago · link · parent
comment 11y ago · link · parent
If you haven't seen a practical example of what it's useful for, that's akin to the attitude of a C programmer not understanding the usefulness of higher order functions. They say, I get 95 percent of the way their with good old functions and function pointers. We would find that absurd, just as how I find the claim that a 'simple practical example of where added power of a macro is useful does not exist' is absurd
For example, see 'A unit testing framework' in 'practical common lisp' available online by Peter seibel. I can't possibly imagine how you'd be able to create a unit testing framework abstraction in Ruby as nice or efficient as the one presented with higher order functions in 26 lines of code. But it'd be cool if anyone could prove otherwise.
comment 11y ago · link · parent
with-open-file(filename, lambda file: do stuff with file)
but with a lisp macro, you only have to write with-open-file (filename):
do stuff with file
The point of an abstraction is so you don't have to think about the implementation. Written like the latter, with-open-file is simply more natural to write this way. You only have to think, "oh, its a construct that opens a file then closes it after the body is done", rather than "oh, its a higher order function that i have to pass another function into that takes the file as an argument..." etc.When you write with-open-file as a macro, it could be implemented as a higher order function, or it could be implemented as a low level set of GOTO statements. It doesn't matter. The macro abstracts away the low level detail, just providing the most natural way for you to use the construct. It might not seem like the macro is doing much in that particular example, but a construct that defines a class (like defclass) is something you can write as a macro, which can expand into functions that do the actual defining. You could write a class defining construct as a higher order function, but then you'd have to constantly worry about how your construct was implemented as a function. instead of just writing something natural like
defclass tiger (animal):
age init-value: 0
name type: string
which you could write if you implemented defclass as a macro.
otherwise,
you'd have to do something crazy stupid like defclass(name='tiger', inherits-from = find-class('animal')
slots=['age, name'] ...)
how could a higher order function possibly implement that without making people using it tear their hair out?
They have to bend to the implementation, not make the abstraction bend to what's natural.comment 11y ago · link · parent
comment 11y ago · link · parent
comment 11y ago · link · parent
> The vast numbers of CL and Scheme compilers are relatively easy to write, exactly because the languages leave (somewhat) less to decide / change at runtime than Python/Ruby/JS.
I would say it's a mistake to conflate Scheme and Common Lisp. Scheme isn't even defined well enough to say something implementation independently about whether the environments should decide things at runtime or not. But Common Lisp as a language has special/dynamically scoped variables and runtime definable macros which make it much more difficult to write a compiler for it. I would say that Common Lisp has way more things to decide at runtime than python or ruby. Maybe they're about the same in terms of difficulty of writing a compiler for, if only because lisp has no parsing/lexing pass. Again, in the end, it's mostly not a language issue. It's how much money and how many compiler experts work on your implementation.
comment 11y ago · link · parent
comment 11y ago · link · parent