An interview with Larry Wall (LinuxVoice)
An interview with Larry Wall (LinuxVoice)
Posted Jul 24, 2015 9:34 UTC (Fri) by rsidd (subscriber, #2582)In reply to: An interview with Larry Wall (LinuxVoice) by dvdeug
Parent article: An interview with Larry Wall (LinuxVoice)
If you want to argue that strings should not silently convert to numbers, that's an argument. It seems far away from any discussion of rational numbers in Perl 6.Floats should not silently convert to rationals. And apparently this doesn't even require an operation. Merely writing "3.14159" makes perl6 treat it as 314159/100000. It's hard to imagine that this has security implications, though. Just needless complexity and inefficiency.
What happens when interfacing with a C library (say GSL)? Are these "rationals" then converted into floats before calling? And are the return values converted back to "rationals"?
Posted Jul 24, 2015 19:19 UTC (Fri)
by raiph (guest, #89283)
[Link]
I can't imagine any language doing that. If your comment is aimed at Perl (5 or 6) then I think this is another manifestation of overall confusion about decimal fractions.
https://en.wikipedia.org/wiki/Decimal#Decimal_fractions
> Merely writing "3.14159" makes perl6 treat it as 314159/100000.
Just for emphasis: https://en.wikipedia.org/wiki/Decimal#Decimal_fractions
Hopefully you'll spend a few seconds reading this wikipedia link and you'll go "ahhh". :)
> What happens when interfacing with a C library (say GSL)?
One uses explicit typing in the signature (the list of parameters) of the Perl 6 functions that call the C functions. For example:
sub add(int32, int32) returns int32 is native("libcalculator") { * }
means that one must call the `add` function with two native 32 bit ints.
See http://doc.perl6.org/language/nativecall#Passing_and_Retu... for some more details.
> Are these "rationals" then converted into floats before calling?
They can be. It's controlled by explicit types and explicit type coercions in the signature. For example:
sub foo(Num(Rat), Num) ...
would be callable with:
foo(13/17, 26e3)
> And are the return values converted back to "rationals"?
Rakudo does not currently support signature based coercion of the return value; I don't know whether there's a plan to one day support that.
An interview with Larry Wall (LinuxVoice)