Reverse interval

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Reverse interval

kilon.alios
hey guys I try to do a reverse interval like this

tp := 0.0.
(0.50 to: 0.01 by: 0.01) do:[ :each| tp := tp + each ].
tp inspect.

and I get nothing , is this a bug or a feature ?

i see a reverse method but looks weird to go that way and not very smalltalky / pharoic 
Reply | Threaded
Open this post in threaded view
|

Re: Reverse interval

EstebanLM
this is correct behaviour (since 0.50 + 0.01 will be bigger than 0.01),
correct way to define this step is: 

(0.50 to: 0.01 by: -0.01) do:[ :each| tp := tp + each ].

(by: -0.01), negative 

Esteban

On 5 Jan 2017, at 09:15, Dimitris Chloupis <[hidden email]> wrote:

hey guys I try to do a reverse interval like this

tp := 0.0.
(0.50 to: 0.01 by: 0.01) do:[ :each| tp := tp + each ].
tp inspect.

and I get nothing , is this a bug or a feature ?

i see a reverse method but looks weird to go that way and not very smalltalky / pharoic 

Reply | Threaded
Open this post in threaded view
|

Re: Reverse interval

kilon.alios
cant say it makes sense for me , why it assumes I want to +0.01 when I give 0.5 to 0.01 when it should assume I want to -0.01 ? is there a scenario that would not be true ? 

in any case its better than reversedo , thank you 

On Thu, Jan 5, 2017 at 10:20 AM Esteban Lorenzano <[hidden email]> wrote:
this is correct behaviour (since 0.50 + 0.01 will be bigger than 0.01),
correct way to define this step is: 

(0.50 to: 0.01 by: -0.01) do:[ :each| tp := tp + each ].

(by: -0.01), negative 

Esteban


On 5 Jan 2017, at 09:15, Dimitris Chloupis <[hidden email]> wrote:

hey guys I try to do a reverse interval like this

tp := 0.0.
(0.50 to: 0.01 by: 0.01) do:[ :each| tp := tp + each ].
tp inspect.

and I get nothing , is this a bug or a feature ?

i see a reverse method but looks weird to go that way and not very smalltalky / pharoic 

Reply | Threaded
Open this post in threaded view
|

Re: Reverse interval

jtuchel
Well, it makes sense if you think of the implementation of to:by:do: as a loop.
How would you implement the stop condition? Does every case where start>stop mean you want to walk backwards?

Joachim

Am 05.01.17 um 09:29 schrieb Dimitris Chloupis:
cant say it makes sense for me , why it assumes I want to +0.01 when I give 0.5 to 0.01 when it should assume I want to -0.01 ? is there a scenario that would not be true ? 

in any case its better than reversedo , thank you 

On Thu, Jan 5, 2017 at 10:20 AM Esteban Lorenzano <[hidden email]> wrote:
this is correct behaviour (since 0.50 + 0.01 will be bigger than 0.01),
correct way to define this step is: 

(0.50 to: 0.01 by: -0.01) do:[ :each| tp := tp + each ].

(by: -0.01), negative 

Esteban


On 5 Jan 2017, at 09:15, Dimitris Chloupis <[hidden email]> wrote:

hey guys I try to do a reverse interval like this

tp := 0.0.
(0.50 to: 0.01 by: 0.01) do:[ :each| tp := tp + each ].
tp inspect.

and I get nothing , is this a bug or a feature ?

i see a reverse method but looks weird to go that way and not very smalltalky / pharoic 



-- 
-----------------------------------------------------------------------
Objektfabrik Joachim Tuchel          [hidden email]
Fliederweg 1                         http://www.objektfabrik.de
D-71640 Ludwigsburg                  http://joachimtuchel.wordpress.com
Telefon: +49 7141 56 10 86 0         Fax: +49 7141 56 10 86 1

Reply | Threaded
Open this post in threaded view
|

Re: Reverse interval

EstebanLM
In reply to this post by kilon.alios

On 5 Jan 2017, at 09:29, Dimitris Chloupis <[hidden email]> wrote:

cant say it makes sense for me , why it assumes I want to +0.01 when I give 0.5 to 0.01 when it should assume I want to -0.01 ? is there a scenario that would not be true ? 

take it this way: in C you’ll need to write: 

for (int i = 0.50; i >= 0.1; i-=0.01) …

which is also explicit about the decreasing “i”… so I don’t understand why it does not makes sense for you :)

Esteban


in any case its better than reversedo , thank you 

On Thu, Jan 5, 2017 at 10:20 AM Esteban Lorenzano <[hidden email]> wrote:
this is correct behaviour (since 0.50 + 0.01 will be bigger than 0.01),
correct way to define this step is: 

(0.50 to: 0.01 by: -0.01) do:[ :each| tp := tp + each ].

(by: -0.01), negative 

Esteban


On 5 Jan 2017, at 09:15, Dimitris Chloupis <[hidden email]> wrote:

hey guys I try to do a reverse interval like this

tp := 0.0.
(0.50 to: 0.01 by: 0.01) do:[ :each| tp := tp + each ].
tp inspect.

and I get nothing , is this a bug or a feature ?

i see a reverse method but looks weird to go that way and not very smalltalky / pharoic 


Reply | Threaded
Open this post in threaded view
|

Re: Reverse interval

kilon.alios
mainly because in my 30 years of coding for fun I never gave a damn what C or other languages try to convince us what expected behaviour is , its one of the big reason why I code in Smalltalk ;) 

plus I hate C/C++ with a vengeance , so :D 

On Thu, Jan 5, 2017 at 10:38 AM Esteban Lorenzano <[hidden email]> wrote:
On 5 Jan 2017, at 09:29, Dimitris Chloupis <[hidden email]> wrote:

cant say it makes sense for me , why it assumes I want to +0.01 when I give 0.5 to 0.01 when it should assume I want to -0.01 ? is there a scenario that would not be true ? 

take it this way: in C you’ll need to write: 

for (int i = 0.50; i >= 0.1; i-=0.01) …

which is also explicit about the decreasing “i”… so I don’t understand why it does not makes sense for you :)

Esteban


in any case its better than reversedo , thank you 

On Thu, Jan 5, 2017 at 10:20 AM Esteban Lorenzano <[hidden email]> wrote:
this is correct behaviour (since 0.50 + 0.01 will be bigger than 0.01),
correct way to define this step is: 

(0.50 to: 0.01 by: -0.01) do:[ :each| tp := tp + each ].

(by: -0.01), negative 

Esteban


On 5 Jan 2017, at 09:15, Dimitris Chloupis <[hidden email]> wrote:

hey guys I try to do a reverse interval like this

tp := 0.0.
(0.50 to: 0.01 by: 0.01) do:[ :each| tp := tp + each ].
tp inspect.

and I get nothing , is this a bug or a feature ?

i see a reverse method but looks weird to go that way and not very smalltalky / pharoic 

Reply | Threaded
Open this post in threaded view
|

Re: Reverse interval

Nicolai Hess-3-2


2017-01-05 9:46 GMT+01:00 Dimitris Chloupis <[hidden email]>:
mainly because in my 30 years of coding for fun I never gave a damn what C or other languages try to convince us what expected behaviour is , its one of the big reason why I code in Smalltalk ;) 

plus I hate C/C++ with a vengeance , so :D 

On Thu, Jan 5, 2017 at 10:38 AM Esteban Lorenzano <[hidden email]> wrote:
On 5 Jan 2017, at 09:29, Dimitris Chloupis <[hidden email]> wrote:

cant say it makes sense for me , why it assumes I want to +0.01 when I give 0.5 to 0.01 when it should assume I want to -0.01 ? is there a scenario that would not be true ? 

We often use (1 to: 0) for an "empty" interval. All this code wouldn't work if we would take this as a reversed (0 to: 1) interval.
 

take it this way: in C you’ll need to write: 

for (int i = 0.50; i >= 0.1; i-=0.01) …

which is also explicit about the decreasing “i”… so I don’t understand why it does not makes sense for you :)

Esteban


in any case its better than reversedo , thank you 

On Thu, Jan 5, 2017 at 10:20 AM Esteban Lorenzano <[hidden email]> wrote:
this is correct behaviour (since 0.50 + 0.01 will be bigger than 0.01),
correct way to define this step is: 

(0.50 to: 0.01 by: -0.01) do:[ :each| tp := tp + each ].

(by: -0.01), negative 

Esteban


On 5 Jan 2017, at 09:15, Dimitris Chloupis <[hidden email]> wrote:

hey guys I try to do a reverse interval like this

tp := 0.0.
(0.50 to: 0.01 by: 0.01) do:[ :each| tp := tp + each ].
tp inspect.

and I get nothing , is this a bug or a feature ?

i see a reverse method but looks weird to go that way and not very smalltalky / pharoic 


Reply | Threaded
Open this post in threaded view
|

Re: Reverse interval

kilon.alios
ok fair enough, I am not saying I am right and you are wrong, just wanted to understand the reasoning 

Would it not "Interval  empty" made more sense ? or is (1 to: 0) convenient in some way in your scenario ?

On Thu, Jan 5, 2017 at 10:59 AM Nicolai Hess <[hidden email]> wrote:
2017-01-05 9:46 GMT+01:00 Dimitris Chloupis <[hidden email]>:
mainly because in my 30 years of coding for fun I never gave a damn what C or other languages try to convince us what expected behaviour is , its one of the big reason why I code in Smalltalk ;) 

plus I hate C/C++ with a vengeance , so :D 

On Thu, Jan 5, 2017 at 10:38 AM Esteban Lorenzano <[hidden email]> wrote:
On 5 Jan 2017, at 09:29, Dimitris Chloupis <[hidden email]> wrote:

cant say it makes sense for me , why it assumes I want to +0.01 when I give 0.5 to 0.01 when it should assume I want to -0.01 ? is there a scenario that would not be true ? 

We often use (1 to: 0) for an "empty" interval. All this code wouldn't work if we would take this as a reversed (0 to: 1) interval.
 

take it this way: in C you’ll need to write: 

for (int i = 0.50; i >= 0.1; i-=0.01) …

which is also explicit about the decreasing “i”… so I don’t understand why it does not makes sense for you :)

Esteban


in any case its better than reversedo , thank you 

On Thu, Jan 5, 2017 at 10:20 AM Esteban Lorenzano <[hidden email]> wrote:
this is correct behaviour (since 0.50 + 0.01 will be bigger than 0.01),
correct way to define this step is: 

(0.50 to: 0.01 by: -0.01) do:[ :each| tp := tp + each ].

(by: -0.01), negative 

Esteban


On 5 Jan 2017, at 09:15, Dimitris Chloupis <[hidden email]> wrote:

hey guys I try to do a reverse interval like this

tp := 0.0.
(0.50 to: 0.01 by: 0.01) do:[ :each| tp := tp + each ].
tp inspect.

and I get nothing , is this a bug or a feature ?

i see a reverse method but looks weird to go that way and not very smalltalky / pharoic 

Reply | Threaded
Open this post in threaded view
|

Re: Reverse interval

Nicolas Passerini

2017-01-05 10:33 GMT+01:00 Dimitris Chloupis <[hidden email]>:
Would it not "Interval  empty" made more sense ? or is (1 to: 0) convenient in some way in your scenario ?

+1
Reply | Threaded
Open this post in threaded view
|

Re: Reverse interval

Nicolai Hess-3-2
In reply to this post by kilon.alios
It is just something I often saw, I don't even know if this is by-design.

I think there are good arguments for both interpretations

2017-01-05 10:33 GMT+01:00 Dimitris Chloupis <[hidden email]>:
ok fair enough, I am not saying I am right and you are wrong, just wanted to understand the reasoning 

Would it not "Interval  empty" made more sense ? or is (1 to: 0) convenient in some way in your scenario ?

On Thu, Jan 5, 2017 at 10:59 AM Nicolai Hess <[hidden email]> wrote:
2017-01-05 9:46 GMT+01:00 Dimitris Chloupis <[hidden email]>:
mainly because in my 30 years of coding for fun I never gave a damn what C or other languages try to convince us what expected behaviour is , its one of the big reason why I code in Smalltalk ;) 

plus I hate C/C++ with a vengeance , so :D 

On Thu, Jan 5, 2017 at 10:38 AM Esteban Lorenzano <[hidden email]> wrote:
On 5 Jan 2017, at 09:29, Dimitris Chloupis <[hidden email]> wrote:

cant say it makes sense for me , why it assumes I want to +0.01 when I give 0.5 to 0.01 when it should assume I want to -0.01 ? is there a scenario that would not be true ? 

We often use (1 to: 0) for an "empty" interval. All this code wouldn't work if we would take this as a reversed (0 to: 1) interval.
 

take it this way: in C you’ll need to write: 

for (int i = 0.50; i >= 0.1; i-=0.01) …

which is also explicit about the decreasing “i”… so I don’t understand why it does not makes sense for you :)

Esteban


in any case its better than reversedo , thank you 

On Thu, Jan 5, 2017 at 10:20 AM Esteban Lorenzano <[hidden email]> wrote:
this is correct behaviour (since 0.50 + 0.01 will be bigger than 0.01),
correct way to define this step is: 

(0.50 to: 0.01 by: -0.01) do:[ :each| tp := tp + each ].

(by: -0.01), negative 

Esteban


On 5 Jan 2017, at 09:15, Dimitris Chloupis <[hidden email]> wrote:

hey guys I try to do a reverse interval like this

tp := 0.0.
(0.50 to: 0.01 by: 0.01) do:[ :each| tp := tp + each ].
tp inspect.

and I get nothing , is this a bug or a feature ?

i see a reverse method but looks weird to go that way and not very smalltalky / pharoic 


Reply | Threaded
Open this post in threaded view
|

Re: Reverse interval

John Pfersich
In reply to this post by kilon.alios
I can see uses for C, but C++ just turns my stomachs, and has since 1986, when I first experienced it 😠.

Sent from my iPhone

> On Jan 5, 2017, at 00:46, Dimitris Chloupis <[hidden email]> wrote:
>
> plus I hate C/C++ with a vengeance , so :D