Information générale
Catégorie:
Codage, syntaxe et commandes
>A follow-up question please. So far, my test shows that program(program(-1)-1) will give what I am looking for.
>Since I write this value to a log file, I want to be sure that it is always a string, not a numeric value. Can you think of a case where program(program(-1)-1) will give a numeric value?
Saw that you already got great responses ;-)
Danger only rises when the levels subtracted are greater than actual stack depth, as *any* negative number as parameter will return numeric.
In practice you are probably safe to chain 2 or even 3 previous levels into single log line unless you are in actual start code.
Trying for more levels default approach should go to astackinfo with a guard, unless specific reason speaks against it.
Of course you could always guard with
program(max(0, program(-1)-wantedlevell)
calls against weird situations, but JR hints at other solution perhaps easier to grok in 6 months.
In this case speed freak in me does neither ;-)
regards
thomas
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement