A new version of Graphics was added to project The Inbox:
http://source.squeak.org/inbox/Graphics-jr.425.mcz ==================== Summary ==================== Name: Graphics-jr.425 Author: jr Time: 30 December 2019, 3:11:45.845402 am UUID: 465fa95d-6a50-a84d-8b73-7e90a2b9d2b5 Ancestors: Graphics-pre.424 Fix message not understood when the right or bottom fraction of a LayoutFrame is nil. =============== Diff against Graphics-pre.424 =============== Item was changed: ----- Method: LayoutFrame>>printOn: (in category 'printing') ----- printOn: aStream super printOn: aStream. aStream nextPutAll: '( '. { {'l'. self leftFraction. self leftOffset}. {'t'. self topFraction. self topOffset}. {'r'. self rightFraction. self rightOffset}. {'b'. self bottomFraction. self bottomOffset} } do: [:spec | aStream nextPutAll: spec first; space. + (spec second ifNil: [0]) printOn: aStream maxDecimalPlaces: 2. - spec second printOn: aStream maxDecimalPlaces: 2. aStream nextPutAll: ((spec third ifNil: [0]) >= 0 ifTrue: ['+'] ifFalse: ['-']). (spec third ifNil: [0]) abs printOn: aStream maxDecimalPlaces: 0] separatedBy: [aStream space]. aStream nextPutAll: ' )'.! |
Ah yes, we had also talked about this in [squeak-dev] LayoutFrame>>#printOn:.
Maybe we should define whether fractions are okay to be nil here. What is the advantage of nil fractions compared to zero fractions? Von: Squeak-dev <[hidden email]> im Auftrag von [hidden email] <[hidden email]>
Gesendet: Montag, 30. Dezember 2019 03:11:52 An: [hidden email] Betreff: [squeak-dev] The Inbox: Graphics-jr.425.mcz A new version of Graphics was added to project The Inbox:
http://source.squeak.org/inbox/Graphics-jr.425.mcz ==================== Summary ==================== Name: Graphics-jr.425 Author: jr Time: 30 December 2019, 3:11:45.845402 am UUID: 465fa95d-6a50-a84d-8b73-7e90a2b9d2b5 Ancestors: Graphics-pre.424 Fix message not understood when the right or bottom fraction of a LayoutFrame is nil. =============== Diff against Graphics-pre.424 =============== Item was changed: ----- Method: LayoutFrame>>printOn: (in category 'printing') ----- printOn: aStream super printOn: aStream. aStream nextPutAll: '( '. { {'l'. self leftFraction. self leftOffset}. {'t'. self topFraction. self topOffset}. {'r'. self rightFraction. self rightOffset}. {'b'. self bottomFraction. self bottomOffset} } do: [:spec | aStream nextPutAll: spec first; space. + (spec second ifNil: [0]) printOn: aStream maxDecimalPlaces: 2. - spec second printOn: aStream maxDecimalPlaces: 2. aStream nextPutAll: ((spec third ifNil: [0]) >= 0 ifTrue: ['+'] ifFalse: ['-']). (spec third ifNil: [0]) abs printOn: aStream maxDecimalPlaces: 0] separatedBy: [aStream space]. aStream nextPutAll: ' )'.!
Carpe Squeak!
|
> What is the advantage of nil fractions compared to zero fractions? No advantages, I think. Just additional ifNil-checks somewhere else. IMO, it should be considered a bug that there are LayoutFrame instances with "nil" fractions. Best, Marcel
|
Hi Marcel, Welcome back & happy new year! :-)
> IMO, it should be considered a bug that there are LayoutFrame instances with "nil" fractions. Good point. There are many users of LayoutFrame that do not use any constructor of the class. For example, see SystemWindow closeBoxFrame.
Now we could either define 2**8 constructors for all of them or, what I would find more simple, do what you proposed in
[squeak-dev] The Trunk: Graphics-mt.406.mcz
[Entwurf]
Diese Nachricht wurde nicht gesendet.Gespeichert am: Heute, 13:41 Uhr
> we might want to change all "getters" into lazy initializers? #leftFraction, #rightFraction, ... or at least return "0" on "ifNil"?
I would prefer the second variant, just for backward compatibility.
And should we maybe initialize the offsets in #leftFraction: etc. if they are zero?
leftFraction: aNumber
^ self leftFraction: aNumber offset: self leftOffset
leftOffset
^ leftOffset ifNil: [0]
Best,
Christoph
Von: Squeak-dev <[hidden email]> im Auftrag von Taeumel, Marcel
Gesendet: Montag, 6. Januar 2020 13:28:02 An: John Pfersich via Squeak-dev Betreff: Re: [squeak-dev] The Inbox: Graphics-jr.425.mcz > What is the advantage of nil fractions compared to zero
fractions?
No advantages, I think. Just additional ifNil-checks somewhere else. IMO, it should be considered a bug that there
are LayoutFrame instances with "nil" fractions.
Best,
Marcel
Carpe Squeak!
|
Hi all, Do we rely anywhere on having nil fractions? Otherwise, just provide #initialize and set all inst var to zero. Le lun. 6 janv. 2020 à 14:01, Thiede, Christoph <[hidden email]> a écrit :
|
> Do we rely anywhere on having nil fractions?
Yes, apparently we do, have a look at #minWidthFrom: ... right := rightFraction ifNil: [1.0]. ... Just fixed this in Graphics-ct.426. -- Sent from: http://forum.world.st/Squeak-Dev-f45488.html
Carpe Squeak!
|
But these are unsent messages in trunk... Le lun. 17 févr. 2020 à 15:52, Christoph Thiede <[hidden email]> a écrit : > Do we rely anywhere on having nil fractions? |
Hm ... sorry, this does not yet convince me. :)
I think the best idea of a default LayoutFrame is fullscreen. This would be LayoutFrame fractions: (0 @ 0 rect: 1 @ 1) offsets: (0 @ 0 rect: 0 @ 0).
Apart from that, there is a big number of nil checks in LayoutFrame. If we introduce something like #fixup, we should also get rid of all these nil checks. Or at least, define a consistent fallback for a nil value, so either we keep the nil values as in Graphics-ct.426, or we introduce #fixUp as in Graphics-nice.425 AND change or delete #minExtentFrom: & Co.
Best, Christoph
Von: Squeak-dev <[hidden email]> im Auftrag von Nicolas Cellier <[hidden email]>
Gesendet: Montag, 17. Februar 2020 16:06:38 An: The general-purpose Squeak developers list Betreff: Re: [squeak-dev] The Inbox: Graphics-jr.425.mcz But these are unsent messages in trunk...
Le lun. 17 févr. 2020 à 15:52, Christoph Thiede <[hidden email]> a écrit :
> Do we rely anywhere on having nil fractions?
Carpe Squeak!
|
Hi Christoph, I do not agree. Most certainly, if some fraction is un-initialized, it's because we only specified the offset and want an absolute layout. Likewise, if offset are un-initialized, it's because we only specified a purely proportional layout and just want that.
This makes zero the best default value (least surprising). if someone wants a full layout default, then he just has to specify LayoutFrame full, or something like that. Look in inbox, this goes very well. Let's eradicate those inaesthetic ifNil: [], YAGNI. Le lun. 17 févr. 2020 à 16:55, Thiede, Christoph <[hidden email]> a écrit :
|
+1
/————————————————————/ For encrypted mail use [hidden email] Get a free account at ProtonMail.com Web: https://objectnets.net and https://objectnets.org https://datascilv.com https://datascilv.org On Feb 17, 2020, at 08:15, Nicolas Cellier <[hidden email]> wrote:
|
Free forum by Nabble | Edit this page |