[squeak-dev] Float parsed as a Fraction bug
Levente Uzonyi
leves at elte.hu
Fri Aug 8 14:55:42 UTC 2014
On Fri, 8 Aug 2014, J. Vuletich (mail lists) wrote:
> Hi Levente,
>
> I just saw your commit to the inbox. I also had fun with this last night, and
> the result is attached. I hope you prefer my version. It is faster and
> shorter.
It looks pretty cool. I tried to avoid Floats, that's why it's slower,
but asymptotically they are the same. I'd rewrite the line
exponent5 _ (without2Factors highBit / (5 log / 2 log)) rounded.
to
exponent5 _ (0.43067655807339306 "2 ln / 5 ln" * without2Factors highBit) truncated.
I didn't think too much about why #truncated is enough, but it seems like
it is.
Also, I'm not sure if #storeOn: has to use the literal form. In Squeak the
debugger uses #printOn: during decompilation.
Levente
>
> It could also make it easier to do the computation just once instead of twice
> (with further refactoring to #isLiteral and #storeOn:).
>
> Cheers,
> Juan Vuletich
>
> Quoting "J. Vuletich (mail lists)" <juanlists at jvuletich.org>:
>
>> Quoting Levente Uzonyi <leves at elte.hu>:
>>
>>>
>>> Try debugging the following snippet:
>>>
>>> | x |
>>> x := 5e-1.
>>> x := x + 1
>>>
>>> You'll find that in Cuis it'll be decomipled as:
>>>
>>> DoIt
>>> | x |
>>> x _ (1/2).
>>> ^ x _ x + 1.
>>>
>>> And the debugger will get confused (in Squeak and Pharo too), because
>>> there's (1/2) instead of 5e-1, which is not a literal.
>>> Also if you press Over, then Proceed in the debugger, then the image will
>>> become unresponsive in Cuis (Cuis4.2-1766).
>>
>> Thanks, Levente. This is what I needed.
>>
>> The debugger becoming unresponsive is an unrelated bug, I just fixed it.
>>
>> The debugger printing the fraction as a division is a rather minor
>> annoyance, not bad enough for giving up the cool '5e-1' syntax, in my
>> opinion. But given that the parser can understand '5e-1', the fraction
>> should be able to print as a literal. Looks like I'm having some numerics
>> fun tonight :)
>>
>>> Levente
>>>
>>>>
>>>>> --
>>>>> best,
>>>>> Eliot
>>
>> Cheers,
>> Juan Vuletich
>
>
More information about the Squeak-dev
mailing list
|