Pharo-dev
By thread
pharo-dev@lists.pharo.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- 1 participants
- 144619 messages
Re: [Pharo-dev] [Article] Elegant Pharo Code
by Sergi Reyner
It may have been mentioned already, but number 7 is wrong, is states:
"7. Sum of the first 64 primes"
when it actually is:
"7. Sum of the primes not larger than 64"
Cheers,
Sergi
2014-07-12 17:02 GMT+01:00 Sven Van Caekenberghe <sven(a)stfx.eu>:
>
> On 08 Jul 2014, at 21:53, kilon alios <kilon.alios(a)gmail.com> wrote:
>
> > Ruby and Pearl look very ugly to me.
> >
> > Programming languages are primarily personal preference.
> >
> > Pharo advantages to me at least are far more than live image, its live
> coding which by the way is different from live image, the IDE tools, the
> factor that is all Pharo objects even when you do assembly coding inside
> Pharo , the libraries of course and last but not least the community.
> >
> > I could name also thousands more advantages that I have found in the
> implementation that I really like as well others I don't. Devil , as they
> say, is in the details. Details are everything , generalisations have
> little meaning.
> >
> > Lovely article Sven , keep them coming. I think Pharo would definitely
> benefit from a cookbook working as a database where pharo coders can use to
> find example code the easy way.
>
> Thanks, Kilon.
>
> > But even articles like this can help a lot, I just wish that there was a
> Pharo wiki to keep these links and see them buried in Pharo news.
>
> Yes, I think we need more/better places to link everything together. A
> curated reading list maybe.
>
> > PS: Sven I am making my own Pharo book called Pharo Universe where I
> want to put things that are not part of PBE or PFTE which can be find here
> https://github.com/kilon/Pharo-Universe and here
> https://ci.inria.fr/pharo-contribution/job/PharoUniverse/ . May I have
> permission to use your articles as chapters for my book ? I will fully
> credit you and link back to your blog posts of course :)
>
> I know you are doing a lot of effort with respect to documentation and
> that is really great and important. I am not sure that copying articles
> that were not meant to be part of a book or larger whole is a good
> solution, for either party, it will give too much repetition and not a lot
> of coherence.
>
> > On Tue, Jul 8, 2014 at 10:33 PM, Paul Davidowitz <pdavidow(a)fastmail.fm>
> wrote:
> > Very nice, except all this could be done in Ruby, also elegantly.
> > The Smalltalk advantage is the live image, and that's where the focus
> > should be.
> >
> >
>
>
>
July 13, 2014
Re: [Pharo-dev] Handling side-scrolls
by Yuriy Tymchuk
Thank you Stef. Iâll take a look.
Uko
On 10 Jul 2014, at 21:21, stepharo <stepharo(a)free.fr> wrote:
> This is not that we do not care. This is that we are busy. If you want to make some step in that direction
> try to OSWindow bug tracker issue and see if it is working for you.
> Because probably that the solution will be using OSWindow
>
> Stef
>
>> Dear Pharo developers,
>>
>> can we deal somehow with this issue: https://pharo.fogbugz.com/f/cases/5296/Fast-Scroll-Down-produces-weird-even… ?
>>
>> Or at least please tell me if someone needs this functionality. Maybe we can just ignore that?
>>
>> Uko
>>
>>
>
>
July 13, 2014
Re: [Pharo-dev] Division isn't correct
by Nicolas Cellier
2014-07-12 17:00 GMT+02:00 Nicolas Cellier <
nicolas.cellier.aka.nice(a)gmail.com>:
>
>
>
> 2014-07-12 13:42 GMT+02:00 Andres Valloud <
> avalloud(a)smalltalk.comcastbiz.net>:
>
> Being consistent then means either abandonning 1/2 = 0.5 but we saw this
>>> has nasty side effects.
>>>
>>
>> Well ok, so letting 1 / 2 = 0.5 answer false has nasty side effects. Why
>> is that? Isn't the code that breaks trying to tell us something? That's
>> what I've been trying to point out. Why rush to defend numerically
>> unstable code? What are we going to preserve, and what will be the example
>> given to others?
>>
>> Andres.
>>
>>
> What apparently breaks Pharo graphics is letting (1 comparisonOp: 1.0) =
> false in Float>>adaptToInteger:andCompare:
> (maybe my mistake, I should ^ operator = #~= rather than ^false)
> At this point, we can't tell that the code is numerically unstable.
> Maybe the Float are very well formed and sufficiently away from int, or
> exactly equal to int...
> Only if we see off-by-one errors can we conclude that there are design
> mistakes.
> Or if we perform a deeper analysis, but it ain't going to be easy.
> To know where it happens, we would have to instrument code (no static
> typing).
>
> It's not un-interesting.
> But it's going to waste a lot of time for a problem we don't yet have...
>
>
So I gave a try to instrumentation with one of my dirtiest hack:
1) define a new Notification subclass: #IntegerFloatComparison
2) raise this signal in Float>>adaptToInteger:andCompare:
IntegerFloatComparison signal
...snip...
3) catch the senders using the message tally:
tally := MessageTally new.
tally spyEvery: 100 on: ['em ezilaitini ot si siht' reverse].
tally class: World class method: World class>>#doOneCycle.
tallyEnd := false.
[(Delay forSeconds: 300) wait. tallyEnd := true] fork.
[[World doOneCycle. Processor yield.tallyEnd] whileFalse]
on: IntegerFloatComparison
do: [:exc | tally tally: exc signalerContext by: 1.
exc resume].
(StringHolder new contents:
(String streamContents: [:s | tally report: s]))
openLabel: 'EndOfStream Spy Results'.
4) do your favourite activity...
After 5 minutes of typical browsing/workspace activity, > 100 000 sends in
Morph, TableLayout, bounds etc...
But are the Float possibly ill-formed?
I modified the signaller:
(self fractionPart = 0) ifFalse: [IntegerFloatComparison signal].
Hmm 0 tallies this time.
So I don't know where exactly Float are required (some primitive do not
accept Fraction I think this is the main reason why some asFloat have been
spreaded...).
But these are innocuous Float.
No numerical unstable code detected by this cheap exercize.
July 12, 2014
Re: [Pharo-dev] [Article] Elegant Pharo Code
by Sven Van Caekenberghe
On 08 Jul 2014, at 21:53, kilon alios <kilon.alios(a)gmail.com> wrote:
> Ruby and Pearl look very ugly to me.
>
> Programming languages are primarily personal preference.
>
> Pharo advantages to me at least are far more than live image, its live coding which by the way is different from live image, the IDE tools, the factor that is all Pharo objects even when you do assembly coding inside Pharo , the libraries of course and last but not least the community.
>
> I could name also thousands more advantages that I have found in the implementation that I really like as well others I don't. Devil , as they say, is in the details. Details are everything , generalisations have little meaning.
>
> Lovely article Sven , keep them coming. I think Pharo would definitely benefit from a cookbook working as a database where pharo coders can use to find example code the easy way.
Thanks, Kilon.
> But even articles like this can help a lot, I just wish that there was a Pharo wiki to keep these links and see them buried in Pharo news.
Yes, I think we need more/better places to link everything together. A curated reading list maybe.
> PS: Sven I am making my own Pharo book called Pharo Universe where I want to put things that are not part of PBE or PFTE which can be find here https://github.com/kilon/Pharo-Universe and here https://ci.inria.fr/pharo-contribution/job/PharoUniverse/ . May I have permission to use your articles as chapters for my book ? I will fully credit you and link back to your blog posts of course :)
I know you are doing a lot of effort with respect to documentation and that is really great and important. I am not sure that copying articles that were not meant to be part of a book or larger whole is a good solution, for either party, it will give too much repetition and not a lot of coherence.
> On Tue, Jul 8, 2014 at 10:33 PM, Paul Davidowitz <pdavidow(a)fastmail.fm> wrote:
> Very nice, except all this could be done in Ruby, also elegantly.
> The Smalltalk advantage is the live image, and that's where the focus
> should be.
>
>
July 12, 2014
Re: [Pharo-dev] Division isn't correct
by Nicolas Cellier
2014-07-12 13:42 GMT+02:00 Andres Valloud <avalloud(a)smalltalk.comcastbiz.net
>:
> Being consistent then means either abandonning 1/2 = 0.5 but we saw this
>> has nasty side effects.
>>
>
> Well ok, so letting 1 / 2 = 0.5 answer false has nasty side effects. Why
> is that? Isn't the code that breaks trying to tell us something? That's
> what I've been trying to point out. Why rush to defend numerically
> unstable code? What are we going to preserve, and what will be the example
> given to others?
>
> Andres.
>
>
What apparently breaks Pharo graphics is letting (1 comparisonOp: 1.0) =
false in Float>>adaptToInteger:andCompare:
(maybe my mistake, I should ^ operator = #~= rather than ^false)
At this point, we can't tell that the code is numerically unstable.
Maybe the Float are very well formed and sufficiently away from int, or
exactly equal to int...
Only if we see off-by-one errors can we conclude that there are design
mistakes.
Or if we perform a deeper analysis, but it ain't going to be easy.
To know where it happens, we would have to instrument code (no static
typing).
It's not un-interesting.
But it's going to waste a lot of time for a problem we don't yet have...
> Or denying the generality of Dictionary: not all objects can be used as
>> key...
>> That's a possible choice, but IMO, this will generate bad feedback from
>> customers.
>> Speaking of consistency, I strongly believe that Squeak/Pharo are on the
>> right track.
>>
>> OK, we can not magically erase inexactness of floating point operations.
>> They are on purpose for the sake of speed/memory footprint optimization.
>> Exceptional values like NaN and Inf are a great deal of
>> complexification, and I'd allways preferred exceptions to exceptional
>> values...
>> But when we can preserve some invariants, we'd better preserve them.
>> Once again, I did not invent anything, that's the approach of lispers,
>> and it seems wise.
>>
>> And last thing, I like your argumentation, it's very logical, so if you
>> have more, you're welcome
>> but I pretty much exhausted mine ;)
>>
>> Nicolas
>>
>>
>> If we can maintain the invariant with a pair of double dispatching
>> methods and coordinated hash, why shouldn't we?
>> Why lispers did it? (Scheme too)
>>
>> For me it's like saying: "since float are inexact, we have a
>> license to
>> waste ulp".
>> We have not. IEEE 754 model insists on operations to be exactly
>> rounded.
>> These are painful contortions too, but most useful!
>> Extending the contortion to exact comparison sounds a natural
>> extension
>> to me, the main difference is that we do not round true or false
>> to the
>> nearest float, so it's even nicer!
>>
>>
>> On 7/11/14 17:19 , Nicolas Cellier wrote:
>>
>>
>>
>>
>> 2014-07-12 1:29 GMT+02:00 Andres Valloud
>> <avalloud(a)smalltalk.__comcastb__iz.net
>> <http://comcastbiz.net>
>> <mailto:avalloud@smalltalk.__comcastbiz.net
>> <mailto:avalloud@smalltalk.comcastbiz.net>>
>> <mailto:avalloud@smalltalk.
>> <mailto:avalloud@smalltalk.>__c__omcastbiz.net
>> <http://comcastbiz.net>
>>
>>
>> <mailto:avalloud@smalltalk.__comcastbiz.net
>> <mailto:avalloud@smalltalk.comcastbiz.net>>>>:
>>
>>
>> I don't think it makes sense to compare
>> floating point
>> numbers to
>> other types of numbers with #=... there's
>> a world of
>> approximations
>> and other factors hiding behind #=, and the
>> occasional true
>> answer
>> confuses more than it helps. On top of
>> that, then
>> you get
>> x = y =>
>> x hash = y hash, and so the hash of
>> floating point
>> values
>> "has" to
>> be synchronized with integers, fractions,
>> scaled
>> decimals,
>> etc...
>> _what a mess_...
>>
>>
>> Yes, that's true, hash gets more complex.
>> But then, this has been discussed before:
>>
>> {1/2 < 0.5. 1/2 = 0.5. 1/2 > 0.5} - > #(false
>> false false).
>>
>> IOW, they are unordered.
>> Are we ready to lose ordering of numbers?
>> Practically, this would have big impacts on
>> code base.
>>
>>
>> IME, that's because loose code appears to work.
>> What
>> enables that
>> loose code to work is the loose mixed mode
>> arithmetic. I could
>> understand integers and fractions. Adding
>> floating point
>> to the mix
>> stops making as much sense to me.
>>
>> Equality between floating point numbers does make
>> sense.
>> Equality
>> between floating point numbers and scaled decimals
>> or
>> fractions...
>> in general, I don't see how they could make sense.
>> I'd
>> rather see
>> the scaled decimals and fractions explicitly
>> converted to
>> floating
>> point numbers, following a well defined procedure,
>> and then
>> compared...
>>
>> Andres.
>>
>>
>> Why do such mixed arithmetic comparisons make sense?
>> Maybe we used floating points in some low level
>> Graphics for
>> optimization reasons.
>> After these optimized operations we get a Float result by
>> contagion, but
>> our intention is still to handle Numbers.
>> It would be possible to riddle the code with explicit
>> asFloat/asFraction
>> conversions, but that does not feel like a superior
>> solution...
>>
>> OK, we can as well convert to inexact first before
>> comparing for
>> this
>> purpose.
>> That's what C does, because C is too low level to ever
>> care of
>> transitivity and equivalence relationship.
>> It's not even safe in C because the compiler can decide
>> to
>> promote to a
>> larger precision behind your back...
>> But let's ignore this "feature" and see what lispers
>> recommend
>> instead:
>>
>> http://www.lispworks.com/____documentation/lcl50/aug/aug-__
>> __170.html
>> <http://www.lispworks.com/__documentation/lcl50/aug/aug-__
>> 170.html>
>>
>> <http://www.lispworks.com/__documentation/lcl50/aug/aug-__
>> 170.html
>> <http://www.lispworks.com/documentation/lcl50/aug/aug-170.html>>
>>
>>
>> It says:
>>
>> In general, when an operation involves both a rational
>> and a
>> floating-point argument, the rational number is first
>> converted to
>> floating-point format, and then the operation is
>> performed. This
>> conversion process is called /floating-point contagion/
>>
>> <http://www.lispworks.com/____reference/lcl50/aug/aug-193.__
>> __html#MARKER-9-47
>> <http://www.lispworks.com/__reference/lcl50/aug/aug-193.__
>> html#MARKER-9-47>
>>
>>
>>
>> <http://www.lispworks.com/__reference/lcl50/aug/aug-193.__
>> html#MARKER-9-47
>> <http://www.lispworks.com/reference/lcl50/aug/aug-193.
>> html#MARKER-9-47>>>.
>>
>> However, for numerical equality comparisons, the
>> arguments are
>> compared
>> using rational arithmetic to ensure transitivity of the
>> equality (or
>> inequality) relation.
>>
>> So my POV is not very new, it's an old thing.
>> It's also a well defined procedure, and somehow better
>> to my taste
>> because it preserve more mathematical properties.
>> If Smalltalk wants to be a better Lisp, maybe it should
>> not
>> constantly
>> ignore Lisp wisdom ;)
>>
>> We can of course argue about the utility of
>> transitivity...
>> As a general library we provide tools like Dictionary
>> that rely on
>> transitivity.
>> You can't tell how those Dictionary will be used in real
>> applications,
>> so my rule of thumb is the principle of least
>> astonishment.
>> I've got bitten once by such transitivity while
>> memoizing... I
>> switched
>> to a better strategy with double indirection as
>> workaround: class ->
>> value -> result, but it was surprising.
>>
>>
>> I'm pretty sure a Squeak/Pharo image wouldn't
>> survive
>> that long
>> to such
>> a change
>> (well I tried it, the Pharo3.0 image survives,
>> but
>> Graphics are
>> badly
>> broken as I expected).
>>
>> That's allways what made me favour casual
>> equality to
>> universal
>> inequality.
>>
>> Also should 0.1 = 0.1 ? In case those two
>> floats have been
>> produced by
>> different path, different approximations they
>> might not
>> be equal...
>> (| a b | a := 0.1. b := 1.0e-20. a+b=a.)
>> I also prefer casual equality there too.
>> Those two mathematical expressions a+b and a are
>> different but both
>> floating point expressions share same floating
>> point
>> approximation,
>> that's all what really counts because in the
>> end, we cannot
>> distinguish
>> an exact from an inexact Float, nor two
>> inexact Float.
>> We lost the history...
>>
>> Also, the inexact flag is not attached to a
>> Float, it's
>> only the
>> result
>> of an operation.
>> Statistically, it would waste one bit for
>> nothing, most
>> floats
>> are the
>> result of an inexact operation.
>> But who knows, both might be the result of exact
>> operations too ;)
>>
>>
>>
>> On 7/11/14 10:46 , stepharo wrote:
>>
>> I suggest you to read the Small
>> number chapter
>> of the
>> Deep into
>> Pharo.
>>
>> Stef
>>
>> On 11/7/14 15:53, Natalia Tymchuk
>> wrote:
>>
>> Hello.
>> I found interesting thing:
>> Why it is like this?
>>
>> Best regards,
>> Natalia
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>
July 12, 2014
Re: [Pharo-dev] Division isn't correct
by Andres Valloud
> Being consistent then means either abandonning 1/2 = 0.5 but we saw this
> has nasty side effects.
Well ok, so letting 1 / 2 = 0.5 answer false has nasty side effects.
Why is that? Isn't the code that breaks trying to tell us something?
That's what I've been trying to point out. Why rush to defend
numerically unstable code? What are we going to preserve, and what will
be the example given to others?
Andres.
> Or denying the generality of Dictionary: not all objects can be used as
> key...
> That's a possible choice, but IMO, this will generate bad feedback from
> customers.
> Speaking of consistency, I strongly believe that Squeak/Pharo are on the
> right track.
>
> OK, we can not magically erase inexactness of floating point operations.
> They are on purpose for the sake of speed/memory footprint optimization.
> Exceptional values like NaN and Inf are a great deal of
> complexification, and I'd allways preferred exceptions to exceptional
> values...
> But when we can preserve some invariants, we'd better preserve them.
> Once again, I did not invent anything, that's the approach of lispers,
> and it seems wise.
>
> And last thing, I like your argumentation, it's very logical, so if you
> have more, you're welcome
> but I pretty much exhausted mine ;)
>
> Nicolas
>
>
> If we can maintain the invariant with a pair of double dispatching
> methods and coordinated hash, why shouldn't we?
> Why lispers did it? (Scheme too)
>
> For me it's like saying: "since float are inexact, we have a
> license to
> waste ulp".
> We have not. IEEE 754 model insists on operations to be exactly
> rounded.
> These are painful contortions too, but most useful!
> Extending the contortion to exact comparison sounds a natural
> extension
> to me, the main difference is that we do not round true or false
> to the
> nearest float, so it's even nicer!
>
>
> On 7/11/14 17:19 , Nicolas Cellier wrote:
>
>
>
>
> 2014-07-12 1:29 GMT+02:00 Andres Valloud
> <avalloud(a)smalltalk.__comcastb__iz.net
> <http://comcastbiz.net>
> <mailto:avalloud@smalltalk.__comcastbiz.net
> <mailto:avalloud@smalltalk.comcastbiz.net>>
> <mailto:avalloud@smalltalk.
> <mailto:avalloud@smalltalk.>__c__omcastbiz.net
> <http://comcastbiz.net>
>
> <mailto:avalloud@smalltalk.__comcastbiz.net
> <mailto:avalloud@smalltalk.comcastbiz.net>>>>:
>
>
> I don't think it makes sense to compare
> floating point
> numbers to
> other types of numbers with #=... there's
> a world of
> approximations
> and other factors hiding behind #=, and the
> occasional true
> answer
> confuses more than it helps. On top of
> that, then
> you get
> x = y =>
> x hash = y hash, and so the hash of
> floating point
> values
> "has" to
> be synchronized with integers, fractions,
> scaled
> decimals,
> etc...
> _what a mess_...
>
>
> Yes, that's true, hash gets more complex.
> But then, this has been discussed before:
>
> {1/2 < 0.5. 1/2 = 0.5. 1/2 > 0.5} - > #(false
> false false).
>
> IOW, they are unordered.
> Are we ready to lose ordering of numbers?
> Practically, this would have big impacts on
> code base.
>
>
> IME, that's because loose code appears to work. What
> enables that
> loose code to work is the loose mixed mode
> arithmetic. I could
> understand integers and fractions. Adding
> floating point
> to the mix
> stops making as much sense to me.
>
> Equality between floating point numbers does make
> sense.
> Equality
> between floating point numbers and scaled decimals or
> fractions...
> in general, I don't see how they could make sense.
> I'd
> rather see
> the scaled decimals and fractions explicitly
> converted to
> floating
> point numbers, following a well defined procedure,
> and then
> compared...
>
> Andres.
>
>
> Why do such mixed arithmetic comparisons make sense?
> Maybe we used floating points in some low level
> Graphics for
> optimization reasons.
> After these optimized operations we get a Float result by
> contagion, but
> our intention is still to handle Numbers.
> It would be possible to riddle the code with explicit
> asFloat/asFraction
> conversions, but that does not feel like a superior
> solution...
>
> OK, we can as well convert to inexact first before
> comparing for
> this
> purpose.
> That's what C does, because C is too low level to ever
> care of
> transitivity and equivalence relationship.
> It's not even safe in C because the compiler can decide to
> promote to a
> larger precision behind your back...
> But let's ignore this "feature" and see what lispers
> recommend
> instead:
>
> http://www.lispworks.com/____documentation/lcl50/aug/aug-____170.html
> <http://www.lispworks.com/__documentation/lcl50/aug/aug-__170.html>
> <http://www.lispworks.com/__documentation/lcl50/aug/aug-__170.html
> <http://www.lispworks.com/documentation/lcl50/aug/aug-170.html>>
>
>
> It says:
>
> In general, when an operation involves both a rational
> and a
> floating-point argument, the rational number is first
> converted to
> floating-point format, and then the operation is
> performed. This
> conversion process is called /floating-point contagion/
>
> <http://www.lispworks.com/____reference/lcl50/aug/aug-193.____html#MARKER-9-…
> <http://www.lispworks.com/__reference/lcl50/aug/aug-193.__html#MARKER-9-47>
>
>
> <http://www.lispworks.com/__reference/lcl50/aug/aug-193.__html#MARKER-9-47
> <http://www.lispworks.com/reference/lcl50/aug/aug-193.html#MARKER-9-47>>>.
>
> However, for numerical equality comparisons, the
> arguments are
> compared
> using rational arithmetic to ensure transitivity of the
> equality (or
> inequality) relation.
>
> So my POV is not very new, it's an old thing.
> It's also a well defined procedure, and somehow better
> to my taste
> because it preserve more mathematical properties.
> If Smalltalk wants to be a better Lisp, maybe it should not
> constantly
> ignore Lisp wisdom ;)
>
> We can of course argue about the utility of transitivity...
> As a general library we provide tools like Dictionary
> that rely on
> transitivity.
> You can't tell how those Dictionary will be used in real
> applications,
> so my rule of thumb is the principle of least astonishment.
> I've got bitten once by such transitivity while
> memoizing... I
> switched
> to a better strategy with double indirection as
> workaround: class ->
> value -> result, but it was surprising.
>
>
> I'm pretty sure a Squeak/Pharo image wouldn't
> survive
> that long
> to such
> a change
> (well I tried it, the Pharo3.0 image survives, but
> Graphics are
> badly
> broken as I expected).
>
> That's allways what made me favour casual
> equality to
> universal
> inequality.
>
> Also should 0.1 = 0.1 ? In case those two
> floats have been
> produced by
> different path, different approximations they
> might not
> be equal...
> (| a b | a := 0.1. b := 1.0e-20. a+b=a.)
> I also prefer casual equality there too.
> Those two mathematical expressions a+b and a are
> different but both
> floating point expressions share same floating
> point
> approximation,
> that's all what really counts because in the
> end, we cannot
> distinguish
> an exact from an inexact Float, nor two
> inexact Float.
> We lost the history...
>
> Also, the inexact flag is not attached to a
> Float, it's
> only the
> result
> of an operation.
> Statistically, it would waste one bit for
> nothing, most
> floats
> are the
> result of an inexact operation.
> But who knows, both might be the result of exact
> operations too ;)
>
>
>
> On 7/11/14 10:46 , stepharo wrote:
>
> I suggest you to read the Small
> number chapter
> of the
> Deep into
> Pharo.
>
> Stef
>
> On 11/7/14 15:53, Natalia Tymchuk wrote:
>
> Hello.
> I found interesting thing:
> Why it is like this?
>
> Best regards,
> Natalia
>
>
>
>
>
>
>
>
>
>
July 12, 2014
Re: [Pharo-dev] Division isn't correct
by Nicolas Cellier
2014-07-12 11:55 GMT+02:00 Andres Valloud <avalloud(a)smalltalk.comcastbiz.net
>:
> You say starting from a more consistent place, but how consistent are =
>> and <= among Numbers without transitivity?
>>
>
> How are numbers consistent to begin with, when for all integers you have
>
> x + 1 ~= x
>
> but for floats, there are a multitude of values such that
>
> x + 1.0 = x
>
> holds? Addition is hardly the only operation that exhibits this kind of
> behavior. Or how about
>
> x = x
>
> being true for the vast majority of cases across all sorts of numbers,
> except when x is NaN? Integers and fractions don't even have a notion of
> -0.0. All of these are already pretty inconsistent without considering
> obvious issues such as
>
> 17 / 20 = 0.85
>
> which in at least some Smalltalks evaluates to true even though it is
> mathematically impossible.
>
> The point is that classes like Float, Integer and Fraction may very well
> have a common superclass. Nonetheless, floating point numbers and
> effectively rationals obey very different rules. Both have their strong
> points, those strengths are maximized with consistency.
>
> Andres.
>
>
Yes, all is true, but it still is the same argument:
- given Float are inexact we have a license to waste ulp
- given Float OPERATIONS do not obey algebraic rules, we have a license to
abandon mathematical properties at will
I claim we'd better not be so liberal.
Maybe I were a bit clumsy, but what I tried to say is that Float are not
inexact per se.
They carrry a well defined exact value.
Only the operations are inexact. But they are the least inexact as possible:
IEEE 754 requires that the operations behaves as if performed EXACTLY then
result is rounded to nearest double
(more exactly to the rounding rule currently in effect, nearest being the
default rule).
Comparisons can be exact, so I see no point in making them inexact.
That's a bit against spirit of IEEE 754, even if they did not rule about
mixed arithmetic.
By making these comparisons exact, we preserve transitivity of = and <=
which is not a bad thing.
You know very well that VW has all the hacks to make hash preserve the
equality of Float/Fraction/etc...
What is the purpose of these hacks?
Make Dictionary & al work?
If so, why stopping in the middle of the bridge and let examples like
http://bugs.squeak.org/view.php?id=3374 miserably fail?
Being consistent then means either abandonning 1/2 = 0.5 but we saw this
has nasty side effects.
Or denying the generality of Dictionary: not all objects can be used as
key...
That's a possible choice, but IMO, this will generate bad feedback from
customers.
Speaking of consistency, I strongly believe that Squeak/Pharo are on the
right track.
OK, we can not magically erase inexactness of floating point operations.
They are on purpose for the sake of speed/memory footprint optimization.
Exceptional values like NaN and Inf are a great deal of complexification,
and I'd allways preferred exceptions to exceptional values...
But when we can preserve some invariants, we'd better preserve them.
Once again, I did not invent anything, that's the approach of lispers, and
it seems wise.
And last thing, I like your argumentation, it's very logical, so if you
have more, you're welcome
but I pretty much exhausted mine ;)
Nicolas
> If we can maintain the invariant with a pair of double dispatching
>> methods and coordinated hash, why shouldn't we?
>> Why lispers did it? (Scheme too)
>>
>> For me it's like saying: "since float are inexact, we have a license to
>> waste ulp".
>> We have not. IEEE 754 model insists on operations to be exactly rounded.
>> These are painful contortions too, but most useful!
>> Extending the contortion to exact comparison sounds a natural extension
>> to me, the main difference is that we do not round true or false to the
>> nearest float, so it's even nicer!
>>
>>
>> On 7/11/14 17:19 , Nicolas Cellier wrote:
>>
>>
>>
>>
>> 2014-07-12 1:29 GMT+02:00 Andres Valloud
>> <avalloud(a)smalltalk.__comcastbiz.net
>> <mailto:avalloud@smalltalk.comcastbiz.net>
>> <mailto:avalloud@smalltalk.__comcastbiz.net
>>
>> <mailto:avalloud@smalltalk.comcastbiz.net>>>:
>>
>>
>> I don't think it makes sense to compare floating
>> point
>> numbers to
>> other types of numbers with #=... there's a world of
>> approximations
>> and other factors hiding behind #=, and the
>> occasional true
>> answer
>> confuses more than it helps. On top of that, then
>> you get
>> x = y =>
>> x hash = y hash, and so the hash of floating point
>> values
>> "has" to
>> be synchronized with integers, fractions, scaled
>> decimals,
>> etc...
>> _what a mess_...
>>
>>
>> Yes, that's true, hash gets more complex.
>> But then, this has been discussed before:
>>
>> {1/2 < 0.5. 1/2 = 0.5. 1/2 > 0.5} - > #(false false
>> false).
>>
>> IOW, they are unordered.
>> Are we ready to lose ordering of numbers?
>> Practically, this would have big impacts on code base.
>>
>>
>> IME, that's because loose code appears to work. What
>> enables that
>> loose code to work is the loose mixed mode arithmetic. I
>> could
>> understand integers and fractions. Adding floating point
>> to the mix
>> stops making as much sense to me.
>>
>> Equality between floating point numbers does make sense.
>> Equality
>> between floating point numbers and scaled decimals or
>> fractions...
>> in general, I don't see how they could make sense. I'd
>> rather see
>> the scaled decimals and fractions explicitly converted to
>> floating
>> point numbers, following a well defined procedure, and then
>> compared...
>>
>> Andres.
>>
>>
>> Why do such mixed arithmetic comparisons make sense?
>> Maybe we used floating points in some low level Graphics for
>> optimization reasons.
>> After these optimized operations we get a Float result by
>> contagion, but
>> our intention is still to handle Numbers.
>> It would be possible to riddle the code with explicit
>> asFloat/asFraction
>> conversions, but that does not feel like a superior solution...
>>
>> OK, we can as well convert to inexact first before comparing for
>> this
>> purpose.
>> That's what C does, because C is too low level to ever care of
>> transitivity and equivalence relationship.
>> It's not even safe in C because the compiler can decide to
>> promote to a
>> larger precision behind your back...
>> But let's ignore this "feature" and see what lispers recommend
>> instead:
>>
>> http://www.lispworks.com/__documentation/lcl50/aug/aug-__170.html
>> <http://www.lispworks.com/documentation/lcl50/aug/aug-170.html>
>>
>>
>> It says:
>>
>> In general, when an operation involves both a rational and a
>> floating-point argument, the rational number is first converted to
>> floating-point format, and then the operation is performed. This
>> conversion process is called /floating-point contagion/
>> <http://www.lispworks.com/__reference/lcl50/aug/aug-193.__
>> html#MARKER-9-47
>>
>> <http://www.lispworks.com/reference/lcl50/aug/aug-193.
>> html#MARKER-9-47>>.
>>
>> However, for numerical equality comparisons, the arguments are
>> compared
>> using rational arithmetic to ensure transitivity of the equality
>> (or
>> inequality) relation.
>>
>> So my POV is not very new, it's an old thing.
>> It's also a well defined procedure, and somehow better to my taste
>> because it preserve more mathematical properties.
>> If Smalltalk wants to be a better Lisp, maybe it should not
>> constantly
>> ignore Lisp wisdom ;)
>>
>> We can of course argue about the utility of transitivity...
>> As a general library we provide tools like Dictionary that rely on
>> transitivity.
>> You can't tell how those Dictionary will be used in real
>> applications,
>> so my rule of thumb is the principle of least astonishment.
>> I've got bitten once by such transitivity while memoizing... I
>> switched
>> to a better strategy with double indirection as workaround: class
>> ->
>> value -> result, but it was surprising.
>>
>>
>> I'm pretty sure a Squeak/Pharo image wouldn't survive
>> that long
>> to such
>> a change
>> (well I tried it, the Pharo3.0 image survives, but
>> Graphics are
>> badly
>> broken as I expected).
>>
>> That's allways what made me favour casual equality to
>> universal
>> inequality.
>>
>> Also should 0.1 = 0.1 ? In case those two floats have
>> been
>> produced by
>> different path, different approximations they might not
>> be equal...
>> (| a b | a := 0.1. b := 1.0e-20. a+b=a.)
>> I also prefer casual equality there too.
>> Those two mathematical expressions a+b and a are
>> different but both
>> floating point expressions share same floating point
>> approximation,
>> that's all what really counts because in the end, we
>> cannot
>> distinguish
>> an exact from an inexact Float, nor two inexact Float.
>> We lost the history...
>>
>> Also, the inexact flag is not attached to a Float, it's
>> only the
>> result
>> of an operation.
>> Statistically, it would waste one bit for nothing, most
>> floats
>> are the
>> result of an inexact operation.
>> But who knows, both might be the result of exact
>> operations too ;)
>>
>>
>>
>> On 7/11/14 10:46 , stepharo wrote:
>>
>> I suggest you to read the Small number chapter
>> of the
>> Deep into
>> Pharo.
>>
>> Stef
>>
>> On 11/7/14 15:53, Natalia Tymchuk wrote:
>>
>> Hello.
>> I found interesting thing:
>> Why it is like this?
>>
>> Best regards,
>> Natalia
>>
>>
>>
>>
>>
>>
>>
>>
>>
>
July 12, 2014
Re: [Pharo-dev] Doc of mustache
by stepharo
Damien
I know but I could not find how yet (I just read that fast in less than
5 min)
What I would like is the following:
I would like to be able to describe menus, page, section for my web
site generator.
So that we do not have to write everything in Smalltalk to generate a
web site.
I should check how this is done in marina but it does not like straigh
forward with the interaction
of the css.
Stef
>
> Le 11 juil. 2014 10:50, "stepharo" <stepharo(a)free.fr
> <mailto:stepharo@free.fr>> a écrit :
> >
> > I would like to see if there is an XHTML outputer that takes it into
> account.
> > I will check pillar.
>
> Pillar uses mustache
>
July 12, 2014
Re: [Pharo-dev] Doc of mustache
by stepharo
Thanks I will turn that into a pfte example :)
Stef
On 11/7/14 10:53, Norbert Hartl wrote:
>
> Am 11.07.2014 um 10:43 schrieb stepharo <stepharo(a)free.fr
> <mailto:stepharo@free.fr>>:
>
>> Hi guys
>>
>> I would like to experiment with template for a small web project I
>> have (my web page) and
>> I would like to try mustache. Is there any tutorial? doc?
>> I know that "jose maria aguerra" wrote a tutorial but I cannot find
>> it anymore.
>
> http://norbert.hartl.name/blog/2013/10/03/mustache-templates-for-smalltalk/
>
> Norbert
>
July 12, 2014
Re: [Pharo-dev] Division isn't correct
by Andres Valloud
> You say starting from a more consistent place, but how consistent are =
> and <= among Numbers without transitivity?
How are numbers consistent to begin with, when for all integers you have
x + 1 ~= x
but for floats, there are a multitude of values such that
x + 1.0 = x
holds? Addition is hardly the only operation that exhibits this kind of
behavior. Or how about
x = x
being true for the vast majority of cases across all sorts of numbers,
except when x is NaN? Integers and fractions don't even have a notion
of -0.0. All of these are already pretty inconsistent without
considering obvious issues such as
17 / 20 = 0.85
which in at least some Smalltalks evaluates to true even though it is
mathematically impossible.
The point is that classes like Float, Integer and Fraction may very well
have a common superclass. Nonetheless, floating point numbers and
effectively rationals obey very different rules. Both have their strong
points, those strengths are maximized with consistency.
Andres.
> If we can maintain the invariant with a pair of double dispatching
> methods and coordinated hash, why shouldn't we?
> Why lispers did it? (Scheme too)
>
> For me it's like saying: "since float are inexact, we have a license to
> waste ulp".
> We have not. IEEE 754 model insists on operations to be exactly rounded.
> These are painful contortions too, but most useful!
> Extending the contortion to exact comparison sounds a natural extension
> to me, the main difference is that we do not round true or false to the
> nearest float, so it's even nicer!
>
>
> On 7/11/14 17:19 , Nicolas Cellier wrote:
>
>
>
>
> 2014-07-12 1:29 GMT+02:00 Andres Valloud
> <avalloud(a)smalltalk.__comcastbiz.net
> <mailto:avalloud@smalltalk.comcastbiz.net>
> <mailto:avalloud@smalltalk.__comcastbiz.net
> <mailto:avalloud@smalltalk.comcastbiz.net>>>:
>
>
> I don't think it makes sense to compare floating point
> numbers to
> other types of numbers with #=... there's a world of
> approximations
> and other factors hiding behind #=, and the
> occasional true
> answer
> confuses more than it helps. On top of that, then
> you get
> x = y =>
> x hash = y hash, and so the hash of floating point
> values
> "has" to
> be synchronized with integers, fractions, scaled
> decimals,
> etc...
> _what a mess_...
>
>
> Yes, that's true, hash gets more complex.
> But then, this has been discussed before:
>
> {1/2 < 0.5. 1/2 = 0.5. 1/2 > 0.5} - > #(false false false).
>
> IOW, they are unordered.
> Are we ready to lose ordering of numbers?
> Practically, this would have big impacts on code base.
>
>
> IME, that's because loose code appears to work. What
> enables that
> loose code to work is the loose mixed mode arithmetic. I could
> understand integers and fractions. Adding floating point
> to the mix
> stops making as much sense to me.
>
> Equality between floating point numbers does make sense.
> Equality
> between floating point numbers and scaled decimals or
> fractions...
> in general, I don't see how they could make sense. I'd
> rather see
> the scaled decimals and fractions explicitly converted to
> floating
> point numbers, following a well defined procedure, and then
> compared...
>
> Andres.
>
>
> Why do such mixed arithmetic comparisons make sense?
> Maybe we used floating points in some low level Graphics for
> optimization reasons.
> After these optimized operations we get a Float result by
> contagion, but
> our intention is still to handle Numbers.
> It would be possible to riddle the code with explicit
> asFloat/asFraction
> conversions, but that does not feel like a superior solution...
>
> OK, we can as well convert to inexact first before comparing for
> this
> purpose.
> That's what C does, because C is too low level to ever care of
> transitivity and equivalence relationship.
> It's not even safe in C because the compiler can decide to
> promote to a
> larger precision behind your back...
> But let's ignore this "feature" and see what lispers recommend
> instead:
>
> http://www.lispworks.com/__documentation/lcl50/aug/aug-__170.html <http://www.lispworks.com/documentation/lcl50/aug/aug-170.html>
>
> It says:
>
> In general, when an operation involves both a rational and a
> floating-point argument, the rational number is first converted to
> floating-point format, and then the operation is performed. This
> conversion process is called /floating-point contagion/
> <http://www.lispworks.com/__reference/lcl50/aug/aug-193.__html#MARKER-9-47
> <http://www.lispworks.com/reference/lcl50/aug/aug-193.html#MARKER-9-47>>.
>
> However, for numerical equality comparisons, the arguments are
> compared
> using rational arithmetic to ensure transitivity of the equality (or
> inequality) relation.
>
> So my POV is not very new, it's an old thing.
> It's also a well defined procedure, and somehow better to my taste
> because it preserve more mathematical properties.
> If Smalltalk wants to be a better Lisp, maybe it should not
> constantly
> ignore Lisp wisdom ;)
>
> We can of course argue about the utility of transitivity...
> As a general library we provide tools like Dictionary that rely on
> transitivity.
> You can't tell how those Dictionary will be used in real
> applications,
> so my rule of thumb is the principle of least astonishment.
> I've got bitten once by such transitivity while memoizing... I
> switched
> to a better strategy with double indirection as workaround: class ->
> value -> result, but it was surprising.
>
>
> I'm pretty sure a Squeak/Pharo image wouldn't survive
> that long
> to such
> a change
> (well I tried it, the Pharo3.0 image survives, but
> Graphics are
> badly
> broken as I expected).
>
> That's allways what made me favour casual equality to
> universal
> inequality.
>
> Also should 0.1 = 0.1 ? In case those two floats have been
> produced by
> different path, different approximations they might not
> be equal...
> (| a b | a := 0.1. b := 1.0e-20. a+b=a.)
> I also prefer casual equality there too.
> Those two mathematical expressions a+b and a are
> different but both
> floating point expressions share same floating point
> approximation,
> that's all what really counts because in the end, we cannot
> distinguish
> an exact from an inexact Float, nor two inexact Float.
> We lost the history...
>
> Also, the inexact flag is not attached to a Float, it's
> only the
> result
> of an operation.
> Statistically, it would waste one bit for nothing, most
> floats
> are the
> result of an inexact operation.
> But who knows, both might be the result of exact
> operations too ;)
>
>
>
> On 7/11/14 10:46 , stepharo wrote:
>
> I suggest you to read the Small number chapter
> of the
> Deep into
> Pharo.
>
> Stef
>
> On 11/7/14 15:53, Natalia Tymchuk wrote:
>
> Hello.
> I found interesting thing:
> Why it is like this?
>
> Best regards,
> Natalia
>
>
>
>
>
>
>
>
July 12, 2014