Re: Phix type check bug

new topic     » goto parent     » topic index » view thread      » older message » newer message

I suspect your main problems right now are all about the "%d".

The manual said...

%d - print an atom as a decimal integer (nb. truncated rather than rounded)

So if s is (say) 0.9999, it would come out as "0".
In fact, somewhat unintentionally but I'm not about to start making it crash now,
should s be {}, or indeed any sequence or string, it'll also come out as 0.

What you probably want is %v, the result of sprint(), which will handle any phix object, instead of %d.

To clarify, [s]printf() mostly mimics the C counterparts, which really only cope with numbers/strings,
whereas [s]print() [without an f] copes with any (single) phix object, of any type and nesting depth,
and the %v format specifier causes the former to invoke the latter.

PS: What I really meant to say is I will make sprintf("%d",{<not atom>}) crash if and only if
there is a pretty strong consensus on this forum to make that change, but not unilaterally.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu