En Wed, 04 Nov 2009 04:50:42 -0300, Alf P. Steinbach <al...@start.no> escribió:
> * Gabriel Genellina: >> I don't understand either. R1 and R2 have *different* semantics.
> Assume that they have the very exact same semantics -- like two TV > sets that look the same and work the same except when you open 'em up > and poke around in there, oh holy cow, in this one there's stuff that > isn't in the other.
>> They don't behave the same.
> Assume that they do -- except when you go poking into the innards.
And the problem is...? That the internal details are different? Who cares? (I'm lost now.)
> En Wed, 04 Nov 2009 04:50:42 -0300, Alf P. Steinbach <al...@start.no> > escribió:
>> * Gabriel Genellina: >>> I don't understand either. R1 and R2 have *different* semantics.
>> Assume that they have the very exact same semantics -- like two TV >> sets that look the same and work the same except when you open 'em up >> and poke around in there, oh holy cow, in this one there's stuff that >> isn't in the other.
>>> They don't behave the same.
>> Assume that they do -- except when you go poking into the innards.
> And the problem is...? > That the internal details are different? Who cares? > (I'm lost now.)
It's a common Usenet phenomenon: the warping thread.
Context is lost.
It is available by going back up-thread but at the cost of some work. :-)
Alf P. Steinbach wrote: > However, the natural semantics is that various logical properties, such > as left, top, right, bottom, width and height, can be varied independently.
But they *CANNOT* be varied independently. A rectangle with side parallel to the axes has exactly 4 degress of freedom, not 6.
>> However, the natural semantics is that various logical properties, >> such as left, top, right, bottom, width and height, can be varied >> independently.
> But they *CANNOT* be varied independently. A rectangle with side > parallel to the axes has exactly 4 degress of freedom, not 6.
Yes <g>. That's the basic idea of the example I presented up-thread, that's discussed here. With R1's state variables width and heigh can be varied independently by direct modification, with R2 it's right and bottom.
The public interface must also make this choice, but it's an independent choice: the internal rectangle representation can have the opposite choice.
And conversely, that means that if the internal representation isn't used directly, then it can be changed without affecting the public interface.
On Wed, 04 Nov 2009 08:50:42 +0100, Alf P. Steinbach wrote: > * Gabriel Genellina:
>> I don't understand either. R1 and R2 have *different* semantics.
> Assume that they have the very exact same semantics
Why would we assume that when you have explicitly told us that they don't?
You stated categorically that they behave differently when you assign to the attribute/property "top". According to your own description, setting R1.top moves the rectangle, while setting R2.top resizes it. Perhaps the difference between "move" and "resize" is too subtle for you, but you can trust us on this, they are different semantics.
> -- like two TV > sets that look the same and work the same except when you open 'em up > and poke around in there, oh holy cow, in this one there's stuff that > isn't in the other.
Whether "top" is an attribute or a property is irrelevant, it is still part of the public API of the class. Such public attributes are NOT private internal details, they are part of the public interface. You've been told this repeatedly. Perhaps one more time may help:
> On Wed, 04 Nov 2009 08:50:42 +0100, Alf P. Steinbach wrote:
>> * Gabriel Genellina: >>> I don't understand either. R1 and R2 have *different* semantics. >> Assume that they have the very exact same semantics
> Why would we assume that when you have explicitly told us that they don't?
> You stated categorically that they behave differently when you assign to > the attribute/property "top".
Uh, severe reading difficulties ... referring to self in plural ... Hm. :-)
But anyway, in the example description I wrote
"With R1 direct changes of left and top keeps the rectangle's size"
and this is in the context of a discussion of modifying data attributes directly versus using properties.
Anyway, if that formulation was confusing I have clarified it later, so you really, ideally, should have no problem grasping this.
> According to your own description, setting > R1.top moves the rectangle, while setting R2.top resizes it. Perhaps the > difference between "move" and "resize" is too subtle for you, but you can > trust us on this, they are different semantics.
No, I would absolutely not trust you Steven, whether that's plural or singular, to assign semantics to my examples.
>> -- like two TV >> sets that look the same and work the same except when you open 'em up >> and poke around in there, oh holy cow, in this one there's stuff that >> isn't in the other.
> Whether "top" is an attribute or a property is irrelevant,
Sorry, that's incorrect.
For example, if it is a read only property than you can't assign to the property.
For another example, if it is a read/write property than it can update any parts of the rectangle represention.
> it is still > part of the public API of the class.
Sorry, that's incorrect; it depends on the class.
> Such public attributes are NOT > private internal details, they are part of the public interface.
Sorry, that's incorrect; it depends on the class, and as far as I know and have been informed here there are no private attributes in Python, just a notational convention.
> You've > been told this repeatedly.
Sorry, but repeating what you want me to have meant in my example, contrary to the direct text of the example, contrary to its context, choosing a meaningless interpreteration of what's left when you have ignored the text, plus contrary to further clarifications, well that's daft to say the least.
> * Steven D'Aprano: >> On Wed, 04 Nov 2009 08:50:42 +0100, Alf P. Steinbach wrote:
>>> * Gabriel Genellina: >>>> I don't understand either. R1 and R2 have *different* semantics. >>> Assume that they have the very exact same semantics
>> Why would we assume that when you have explicitly told us that they >> don't?
>> You stated categorically that they behave differently when you assign >> to the attribute/property "top".
> Uh, severe reading difficulties ... referring to self in plural ... Hm. :-)
> But anyway, in the example description I wrote
> "With R1 direct changes of left and top keeps the rectangle's size"
> and this is in the context of a discussion of modifying data attributes > directly versus using properties.
Perhaps this makes it more clear: in R1, which has a width/height based rectangle representation, assigning directly to the top data attribute /effectively/ moves the rectangle vertically without changing its height, since the height attribute is unchanged.
But that does not reflect any intended semantics, it's not a requirement; it's an implementation artifact, a behavior that just results from direct modification and the choice of a particular rectangle representation.
Real world Python example of that kind of artifact: as discussed in some other thread here, doing open( ..., 'r+' ) followed by write followed directly by read will on some implementations/systems produce garbage. Presumably because those implementations use C "FILE*" to implement the functionality, and implements it by a fairly direct mapping of calls down to the C level, where this sequence is in general Undefined Behavior. You might regard it as semantics, and it's quite real and presumably in a sense well-defined for the particular implementation on the particular system, but it's not part of any intended semantics, and any who relies on that behavior is doing it at other's risk.
For the R1 class the indended semantics, the specification that the programmer was handed down or produced or had in mind, might include just rectangle construction, checking intersection with other rectangle, and obtaining any of three pairs of values: left upper corner, right lower corner and width+height.
>>> However, the natural semantics is that various logical properties, >>> such as left, top, right, bottom, width and height, can be varied >>> independently. >> But they *CANNOT* be varied independently. A rectangle with side >> parallel to the axes has exactly 4 degress of freedom, not 6.
> Yes <g>. That's the basic idea of the example I presented up-thread, > that's discussed here. With R1's state variables width and heigh can be > varied independently by direct modification, with R2 it's right and > bottom.
> The public interface must also make this choice, but it's an independent > choice: the internal rectangle representation can have the opposite > choice.
> And conversely, that means that if the internal representation isn't > used directly, then it can be changed without affecting the public > interface.
And that's exactly what everyone is saying - so we all agree then!
> En Wed, 04 Nov 2009 18:08:49 -0300, Alf P. Steinbach <al...@start.no> > escribió: >> * Terry Reedy: >>> Alf P. Steinbach wrote:
>>>> However, the natural semantics is that various logical properties, >>>> such as left, top, right, bottom, width and height, can be varied >>>> independently. >>> But they *CANNOT* be varied independently. A rectangle with side >>> parallel to the axes has exactly 4 degress of freedom, not 6.
>> Yes <g>. That's the basic idea of the example I presented up-thread, >> that's discussed here. With R1's state variables width and heigh can >> be varied independently by direct modification, with R2 it's right and >> bottom.
>> The public interface must also make this choice, but it's an >> independent choice: the internal rectangle representation can have the >> opposite choice.
>> And conversely, that means that if the internal representation isn't >> used directly, then it can be changed without affecting the public >> interface.
> And that's exactly what everyone is saying - so we all agree then!