3 ms·
C++ has many pure functional features that C lacks. For example immutable methods with const and Lambdas. Wouldn't these features make it easier target to C++ r
by lbenes 10y ago
C++ has many pure functional features that C lacks. For example immutable methods with const and Lambdas. Wouldn't these features make it easier target to C++ rather than C? Do these functional features only make it easier for a human to write functional code or is there some other reason these Lisps all use C?
- palunon 10y agoLambdas are actually just a nice way to write functions/function objects without polluting the scope. I guess a compiler have no such problems. Immutable methods are the same thing as a safety check for humans. As you want to check for these things anyway (since you probably don't want errors to come from the c++ compiler), they don't add value. (AFAIK, they may trigger optimizations, but so does passing const parameters to a free function, which is the C equivalent)
- qwertyuiop924 10y agoIf you're passing around your environments in the C code (which you should be doing anyways), than there is no reason it would be easier to target C++.
- wyager 10y agoIf you're writing a compiler, you're going to want to explicitly manage closures and function pointers anyway.
- nv-vn 10y agoSince you're compiling and not interpreting, you can do all the checks that a variable doesn't get mutated at compile-time. There's no need to defer these checks into the C code.