Stack objects are created with "$" so these are on the stack and then placed into the Table? So if this was in a function and the function returned, the Table (lets assume it was global) would now be pointing to destroyed stack variables? Is that the correct interpretation?
Is this all done with header files and the preprocessor? It looks like that is the case - if so, I am impressed at the dances you got it to do ;) Also, have you read http://www.amazon.com/Interfaces-Implementations-Techniques-... which does some "Object Orientation" in C tricks?
I'm just guessing here, but I assume the variables are created on the stack, then copied into the table object, rather than references being passed to the table. So when the function would end, the original variables would be destroyed, but the copies would remain.
This is correct. "Table" is a datatype which copies the values into the table, while "Dict" is a data type that holds references to the objects. The same semantics hold for "Array" and "List".
Although not perfect this was probably the best way I could have designed such structures. There is some info in the header files as to how to use them.
> Well Objective C is a separate language entirely.
Not quite; Objective-C is a superset of C. You can write pure C and compile it as Objective-C all day long.
This is an important point because people think their C knowledge doesn't translate to Objective-C, mainly because people say things like "it's entirely different". At its core, it really isn't -- the superset syntax becomes straight C underneath.
Beyond that, even, you can write Objective-C in pure C99. The brackets, class definitions, and all the rest is a sort of syntactic sugar that converts directly to a handful of straight C functions (you can find them all here: https://developer.apple.com/library/mac/#documentation/Cocoa...)
What are the performance implications of these features? How do they compare with similar C++ functionality, especially things they do at compile-time? Can I have a pretty graph?
What trade-offs were made? Can they be improved? Are certain aspects or semantics optional? Do you pay the price of linking this library simply by linking it, or do you "only pay for what you use"?
Is it safe? Type-safe? If not, what's required to make them safe?
If you don't answer these questions, somebody like me will who's ignorant of how this is supposed to work will produce their own data. That's not good, you understand how it's supposed to be used.
That's a lot of questions. I will do my best to answer them but note I am not trying to sell a language here. I'm just a student and wanted to show an interesting project I'd been playing with.
The performance implications are much like vtable lookup in C++. Generic functions are essentially overloaded and their function pointer looked up at runtime. The main tradeoff over C++ is that rich types don't play well when allocated on the stack as destructors cannot be automatically called on frame exit.
The added semantics are not optional, but you can still program in standard C while avoiding the defined keywords and functions and the interaction should not be troublesome at all. There is no price for linking the library.
It is not type-safe and employs runtime type checking where inserted by the user - but also this allows for duck typing and more generic code so perhaps it is not a bad thing all round.
I hope that helps. Any more questions feel free to drop me an e-mail.
IMO, any new language that has inclusion as a mechanism for modules is not just at a developmental dead end, it's over the curb at the end of that dead end and in the retention pond beyond.
The parser and compiler should only need to examine each source file once.
Yeah using $ was pretty cheeky. I use a few other GCC specific features such as nested functions, which is why I specify that the standard is GNU99 rather than C99. If you have any errors on mac please post a bug report as I don't have a machine to test on! Thanks.
I have two things that would make me very happy in C: Overloadable operators and constructors/destructors. I have not been able to come up with a way to do that yet, but maybe if I change the entire way I write C like you did with the syntax changes, it might actually work. I'm going to have to think about that!
I was working a similar project a few months ago. Wish I hade more time to complete. Mine was a bit more of a ripoff of Obj-C than anything. https://github.com/ryanashcraft/Classified-C
> What I don't enjoy in Haskell is writing small detailed algorithms in a functional style.
You can hop around this easily using the ST monad. It's less elegant than usual Haskell and often less elegant than languages where mutation is 'native', but it does its job.
it always annoys me when people can't properly write about what they've done. For example, the description says, with reference to C: "I've turned it into something of a dynamic and powerful functional language which it might have once been" ...is his wording wrong or what? ...'cause C has never been a "powerful functional language"
Perhaps 'it might once have become' would make more sense there, in that it was a development the author thought could have happened in the past but did not?
not everyone is good at writing and expressing themselves in written language. quite a lot of good engineers actually struggle with this. definitely no need to be "annoyed", may be try helping him out?
I don't mean literary style or PR magic or anything, just using the words right so what comes out is exactly what you mean, not something that means something different but you have to use the context to understand what he probably thought about when writing that... If one can express his thought in a programming language, one can also use basic grammar like tenses and modes to say what he means... all this "words don't matter" attitude is what eventually ends up spreading and making wonderful pieces of software engineering unusable because of broken docs...
I am confused by the implication of this code
Stack objects are created with "$" so these are on the stack and then placed into the Table? So if this was in a function and the function returned, the Table (lets assume it was global) would now be pointing to destroyed stack variables? Is that the correct interpretation?Is this all done with header files and the preprocessor? It looks like that is the case - if so, I am impressed at the dances you got it to do ;) Also, have you read http://www.amazon.com/Interfaces-Implementations-Techniques-... which does some "Object Orientation" in C tricks?