Liste des Groupes | Revenir à cl c |
bart <bc@freeuk.com> wrote:
It would probably be done by a script. This resulting code is not something to be written or consumed by a human. Which is an odd thing to say about a HLL.I've seen a 33KB C file that expanded to 4MB after preprocessing. MacrosIf macros were forbiden authors would probably write 4MB "by hand"
are evil.
(or rather using editor cut and paste). Actually, creating first
version probably would be not that hard, but maintanence would
take a lot of effort (due to volume).
Of course, macro generated code is likely to contain significantHow about writing decent, sensible code in the first place?
fraction of useless instructions, but removing them by hand would
be substantial work. And trying to directly produce trimmed
version would need a lot of work. It is much cheaper to
depend on optimizer to remove redundancies and useless instructions.
Assuming that hand written version would be 80% smaller, you wouldYou haven't seen this example, you don't know how bad it is, or how effective it was as a solution to whatever problem it was trying to solve, and yet YOU'RE MAKING EXCUSES FOR IT!
have 800KB to write, that is more than 20 times the original
source. So in this case macros probably saved about 95% of
work needed when coding without macros.
So that means there's nothing wrong with it? Remember this is one expression.Here's a nice example:Not bad, I sometimes had to look for bugs in much bigger piece of
>
op_arith(L, l_addi, luai_numadd);
>
Innocent-looking isn't it? It expands to this:
>
{TValue*v1=(&((base+((((int)((((i)>>((((0+7)+8)+1)))&((~((~(Instruction)0)<<(8)))<<(0)))))))))->val);TValue*v2=(&((base+((((int)((((i)>>(((((0+7)+8)+1)+8)))&((~((~(Instruction)0)<<(8)))<<(0)))))))))->val);{StkId
ra=(base+(((int)((((i)>>((0+7)))&((~((~(Instruction)0)<<(8)))<<(0)))))));if(((((v1))->tt_)==(((3)|((0)<<4))))&&((((v2))->tt_)==(((3)|((0)<<4))))){lua_Integer
i1=(((v1)->value_).i);lua_Integer
i2=(((v2)->value_).i);pc++;{TValue*io=((&(ra)->val));((io)->value_).i=(((lua_Integer)(((lua_Unsigned)(i1))+((lua_Unsigned)(i2)))));((io)->tt_=(((3)|((0)<<4))));};}else{lua_Number
n1;lua_Number
n2;if((((((v1))->tt_)==(((3)|((1)<<4))))?((n1)=(((v1)->value_).n),1):(((((v1))->tt_)==(((3)|((0)<<4))))?((n1)=((lua_Number)(((((v1)->value_).i)))),1):0))&&(((((v2))->tt_)==(((3)|((1)<<4))))?((n2)=(((v2)->value_).n),1):(((((v2))->tt_)==(((3)|((0)<<4))))?((n2)=((lua_Number)(((((v2)->value_).i)))),1):0))){pc++;{TValue*io=((&(ra)->val));((io)->value_).n=(((n1)+(n2)));((io)->tt_=(((3)|((1)<<4))));};}};};};
>
From this, I had to find the bug in my compiler.
code.
Here you are making excuses again. Yes, Lua uses tags on some 64-bit value; so what? That can be done using ordinary code. Or if macros have to be used, they can be simple too.(Lua is an interpreter; I write interpreters and they are several timesIIUC Lua has some interesting properties. Above I see masking and
faster than Lua for equivalant inputs. I don't need to use such tricks.)
tag manipulations, presumably this is needed to implement Lua
properties.
I would expect that Lua has more than one artithemeticAny reason to uses *seven* levels of macro invocation? That is all in one branch.
operation, so sharing code saves coding effort (actually, most
of tag mainipulations probably can be shared by all Lua instructions).
Les messages affichés proviennent d'usenet.