The style reminds me of some J implementations! #define DO(n,x) {I i=0,_n=(n);for(;i http://code.jsoftware.com/wiki/Essays/Incunabulum
Cello – A library that brings higher level programming to C
141–150 of 158 posts
Re: Cello – A library that brings higher level programming to C
#142The style reminds me of some J implementations! #define DO(n,x) {I i=0,_n=(n);for(;i http://code.jsoftware.com/wiki/Essays/Incunabulum
Re: Cello – A library that brings higher level programming to C
#143Earlier quoted context omitted.
Presumably, people who wanted to talk about Cello in this thread, not Rust, and are having the signal-to-noise ratio reduced by this derailing.
There's literally not a single comment in this thread comparing C to Rust, and yet Rust fanatics are the ones derailing here? Care to elaborate, my good friend?
Re: Cello – A library that brings higher level programming to C
#144The style reminds me of some J implementations! #define DO(n,x) {I i=0,_n=(n);for(;i http://code.jsoftware.com/wiki/Essays/Incunabulum
The worst part of that macro is that it is inherently unhygienic: it leaks the variable name 'i' up the scope
Re: Cello – A library that brings higher level programming to C
#145Earlier quoted context omitted.
You're being pedantic about reserved words?
I had that same problem. I wrote a C library [1] that has a structure field named "class". It's "class" because the protocol being described (DNS) calls that particular field "class" [2]. And I'm not about to pay lip service to an abomination like C++ [3][4]. [1] https://github.com/spc476/SPCDNS [2] https://github.com/spc476/SPCDNS/blob/ca5052c3d0c3252071a18e... [3] I am NOT a fan of C++. [4] But I had to anyway, but…
Re: Cello – A library that brings higher level programming to C
#146Earlier quoted context omitted.
I'd remove the “faux”. Cello is dynamically typed.
Then you could say that just using void-pointers in C that C is also dynamically typed.
Re: Cello – A library that brings higher level programming to C
#147Earlier quoted context omitted.
I'd remove the “faux”. Cello is dynamically typed.
Then you could say that just using void-pointers in C that C is also dynamically typed.
Re: Cello – A library that brings higher level programming to C
#148Earlier quoted context omitted.
Then you could say that just using void-pointers in C that C is also dynamically typed.
In C you would only use void pointers very occasionally, to work around the lack of generics/templates in data structures. Most of the time, objects have types. In Cello, everything is a void pointer. Limited as it is, compiler type checking in C is still valuable.
Re: Cello – A library that brings higher level programming to C
#149Earlier quoted context omitted.
The worst part of that macro is that it is inherently unhygienic: it leaks the variable name 'i' up the scope
Presumably there is a #define I int floating around somewhere so that need not be the case (note the capital I inside the curly brace).
float i = 10;
DO({i+= 10;} 20);
will evaluate to this, modifying the "i" declared inside the macro float i_1 = 10;
{I i_2=0,_n=(n);for(;i_2Re: Cello – A library that brings higher level programming to C
#150Earlier quoted context omitted.
Presumably there is a #define I int floating around somewhere so that need not be the case (note the capital I inside the curly brace).
the Big "I" is the type, which is a macro parameter. The variable name "i" is not a parameter. If There is another variable "i" in the scope, the loop variable will shadow it in the DO statement. Something like this float i = 10; DO({i+= 10;} 20); will evaluate to this, modifying the "i" declared inside the macro float i_1 = 10; {I i_2=0,_n=(n);for(;i_2
typedef long I;
#define DO(n,x) {I i=0,_n=(n);for(;i
(I added a comma here after the }, 20 is the x parameters) DO({i+= 10;}, 20);
expands to: typedef long I;
{I i=0,_n=({i+= 10;});for(;i
The '20' presumably should have been some kind of function call or action to repeat and the 'n' should have been the count (the reverse from your example).So that would make this:
typedef long I;
{I i=0,_n=(20);for(;i
You're still right that it will shadow any 'i' declared outside and so it won't work but it will not overwrite it as far as I can see. You'll just end up right where you started.What I really don't get is if they're going to use _n for the count anyway why not count it down to 0, that way the whole 'i' could be avoided.
(you'd still have a problem with _n but that could be overcome with a convention, which of course someone will forget with some nasty bug as a result)