Nymph: A slightly different version of C
github.com
github.com
https://github.com/roecrew/nymph/blob/master/nymph/example/n...
int *myDictLen = malloc(sizeof(int));
*myDictLen = 0;
I strongly suspect that the author is basically unaware of the & address operator. I would suggest that learning C syntax is a prerequisite to improving it.All I see is "C with different syntax". That could easily be a challenging side project whilst learning compilers / language design.
I've always found changing things up a useful means of practice. I wanted to learn how HTTP servers worked. I wanted to learn more Lisp. I implemented it in Common Lisp. I learned a lot.
{
int x = (side_effect(), initializing_expr());
int y = x + 42;
From C99 onward, this could be: {
side_effect();
int x = initializing_expr();
int y = x + 2;
We use the comma operator in for loops because it has places in its syntax which take one expression. This limitation can arise in other contexts, like some macro MAC(E) where E must be a single expression. If want to to have two sequenced effects in there, we can use MAC((eff1, eff2)).Just stack/automatically allocate the resource and take the address with & then pass the pointer around. Because the data is automatically cleaned up you know you won't have any leaks (and certain whole other classes of bugs).
EDIT - Consider:
int myDictLen = 0;
int* myDictLenPtr = &myDictLen;
/* now you can pass around the pointer myDictLenPtr
to functions that can used an int* and it will be
available in this scope and automatically cleaned
up for you. */int var_a = 5;
and use &var_a when you want to acess that variable as a pointer within that scope. Not only is this more efficient, it is much easier to read.
Without a shred of specification, only code: I predict, absolutely not a damn thing.
If code is your specification, then every time you type "git commit" you're changing the specification.
On the plus side, your code always implements the specification 100%, at all times.
The public and private stuff is irksome. Make one of them default. Have a way to declare that all names in a region of a file are public or private so that programmers don't have to repeat themselves.
private: // default: can be omitted
void helper_function_a(foo *f) { ... }
void helper_function_b(foo *f) { ... }
public:
int api_function(...) { ... }Edit; Adding a bit more; when I think of a C like language I'd like to have, I'd like exceptions (naive impl with setjmp longjmp for example), and Java like "everything's a pointer, all allocation on the heap". And reference counting gc. I don't think anyone else would like this :)
I seem to recall that the bindings weren't totally up-to-date though. The latest GTK outpaced the available Vala bindings.
- String type that has the memory managed by the runtime
- Some perl: if (buf =~ /regexp/)
- associative arrays as a built in thing
and I have such a language, sort of, here:I’m doing a (free) operating system (just a hobby, won’t be big and professional like gnu) ...
https://softwareengineering.stackexchange.com/questions/2546...
"A hand-written recursive-descent C++ parser has replaced the YACC-derived C++ parser from previous GCC releases."
"GCC switched to hand-written parsing because error messages are more meaningful when using recursive descent techniques. Also, C++ is becoming such a (syntactically) complex language to parse that using parser generators is not worthwhile for it."
It is strange, because the more complex the language, the more I would expect that they would move to lexer/parser generator tools, while it seems to be exactly the other way around.
Goals
...