[#796] Re: value of assignment (Re: Order of the value of an expression changed? (PR#579)) — Sean Chittenden <sean@...>

> sean@chittenden.org wrote:

33 messages 2003/02/06
[#798] Re: value of assignment (Re: Order of the value of an expression changed? (PR#579)) — matz@... (Yukihiro Matsumoto) 2003/02/06

Hi,

[#826] Re: value of assignment (Re: Order of the value of an expression changed? (PR#579)) — Sean Chittenden <sean@...> 2003/02/10

> |I have read the thread and I think this is a pretty bad change. I

[#827] Re: value of assignment (Re: Order of the value of an expression changed? (PR#579)) — nobu.nokada@... 2003/02/10

Hi,

[#828] Re: value of assignment (Re: Order of the value of an expression changed? (PR#579)) — Sean Chittenden <sean@...> 2003/02/11

> > #BEGIN test.rb

[#829] Re: value of assignment (Re: Order of the value of an expression changed? (PR#579)) — matz@... (Yukihiro Matsumoto) 2003/02/11

Hi,

[#830] Re: value of assignment (Re: Order of the value of an expression changed? (PR#579)) — Sean Chittenden <sean@...> 2003/02/11

> |What was wrong with having the receiver set the return value though?

[#834] Re: value of assignment (Re: Order of the value of an expression changed? (PR#579)) — Matt Armstrong <matt@...> 2003/02/11

Sean Chittenden <sean@chittenden.org> writes:

[#835] Re: value of assignment (Re: Order of the value of an expression changed? (PR#579)) — Sean Chittenden <sean@...> 2003/02/11

> > f = Foo.new()

[#801] class of $1, $2 in 1.8.0 — dblack@...

Hi --

31 messages 2003/02/07
[#802] Re: class of $1, $2 in 1.8.0 — nobu.nokada@... 2003/02/07

Hi,

[#803] Re: class of $1, $2 in 1.8.0 — dblack@... 2003/02/07

Hi --

[#804] Re: class of $1, $2 in 1.8.0 — matz@... (Yukihiro Matsumoto) 2003/02/07

Hi,

[#805] Re: class of $1, $2 in 1.8.0 — dblack@... 2003/02/07

Hi --

[#806] Re: class of $1, $2 in 1.8.0 — "J.Herre" <jlst@...> 2003/02/07

[#807] Re: class of $1, $2 in 1.8.0 — Matt Armstrong <matt@...> 2003/02/07

J.Herre <jlst@gettysgroup.com> writes:

[#808] Re: class of $1, $2 in 1.8.0 — dblack@... 2003/02/07

Hi --

[#809] Re: class of $1, $2 in 1.8.0 — Ryan Pavlik <rpav@...> 2003/02/07

On Sat, 8 Feb 2003 06:52:17 +0900

[#810] Re: class of $1, $2 in 1.8.0 — dblack@... 2003/02/07

Hi --

[#889] Bob Jenkins' hashing implementation in Ruby — Mauricio Fern疣dez <batsman.geo@...>

16 messages 2003/02/28
[#892] Re: Bob Jenkins' hashing implementation in Ruby — ts <decoux@...> 2003/03/01

>>>>> "M" == Mauricio Fern疣dez <Mauricio> writes:

[#893] Re: Bob Jenkins' hashing implementation in Ruby — Mauricio Fern疣dez <batsman.geo@...> 2003/03/01

On Sat, Mar 01, 2003 at 08:42:40PM +0900, ts wrote:

Re: value of assignment (Re: Order of the value of an expression changed? (PR#579))

From: Mathieu Bouchard <matju@...>
Date: 2003-02-12 20:55:51 UTC
List: ruby-core #867
On Wed, 12 Feb 2003, Pit Capitain wrote:

> Yes, this is true. I see your point. But, at least for me, after
>   o.quality = 999'999
> it feels strange that
>   o.quality == 100
> The auto-adjust code might be handy if you always know what you're 
> doing, but it could also hide some errors in your program. I think if 
> I'd want to auto-adjust instead of raising an error, I would code it 
> like this:
>   def adjust_to_percent( value )
>     [[value,0].max,100].min
>   end
>   percent = o.quality = adjust_to_percent( 999'999 )
> to make it obvious whats going on.

This is the old debate between implicitness and explicitness. I am not
sure whether I would actually code that way. I'm always keeping
automatically generated GUI's in mind, and for some reason I had thought
that making it auto-adjust would be good, but now I'm no longer very
sure... My actual solution to that problem is more like:

1. Make a type declaration for the :quality property. Its type would be
either 0..100 or And[Integer,0..100] depending on circumstances.

2. Optionally check the validity of the value assigned to the property. I
consider it a good thing to modularize type-checking out of
type-declaration, which explains the "optional" here. The reason for that
modularization is that type-decls are useful in other circumstances
(marshalling... runtime help... automatic GUI generation... etc)

3. Actual policies of auto-adjust (and other recovery strategies) are a
responsibility of the GUI controls (or of a common library of policies
being used by the GUI library)

I've been thinking almost like this for a while but hadn't taken the time
to clarify my ideas...

I'm still not to sure about the auto-adjust, because automatic casting is
one kind of auto-adjust (it's just that it recreates the value as being of
a different class instead of the same class), and I'm not necessarily
willing to make it go away, and think that all kinds of auto-adjusting
should be done at the same level.

Many general software design questions still unsolved...

________________________________________________________________
Mathieu Bouchard                       http://artengine.ca/matju


In This Thread

Prev Next