Fwd: Pharo and scaled decimals

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

Fwd: Pharo and scaled decimals

Marcus Denker-4
I added this as issue 10016 to the new tracker.

Begin forwarded message:

From: David Gorisek <[hidden email]>
Subject: Re: Pharo and scaled decimals

Hello all,

I am testing Pharo and I have noticed that the Pharo compiler does not treat ScaledDecimals the same way they are treated in other Smalltalk dialects (e.g. VW, VAST, Dolphin, STX, etc.).

For example the following is a valid code representing an instance of ScaledDecimal/FixedPoint in all other dialect.

1.0s  + 2.0s

In Phare the code above wont compile, it has to be written as:

1.0s1 + 2.0s1

So I have made the following quick change to make Pharo compatible with other Smalltalk dialects. Maybe this change could be included in the next version of Pharo?

SqNumberParser>>#readScale
    "read the scale if any (stored in instVar).
    Answer true if found, answer false if none.
    If scale letter is not followed by a digit, this is not considered as an error.
    Scales are always read in base 10, though i do not see why..."

    scale := 0.
    sourceStream atEnd
        ifTrue: [ ^ false ].
    (sourceStream peekFor: $s)
        ifFalse: [ ^ false ].
    scale := self nextUnsignedIntegerOrNilBase: 10.
    scale
        ifNil: [
            scale := 0.
            (sourceStream peek ifNil: [false] ifNotNil: [ :nextChar | nextChar isLetter])
                ifTrue: [
                    sourceStream skip: -1.    "ungobble the s"
                    ^ false ]
                ifFalse: [ ^ true ] ].
    ^ true







Reply | Threaded
Open this post in threaded view
|

Re: Fwd: Pharo and scaled decimals

jannik laval
Hi,
Should we already use the new tracker ?

Is it possible to update the page: http://www.pharo-project.org/community/issue-tracking
It redirect to the google code issue tracker.

Jannik

2013/3/14 Marcus Denker <[hidden email]>
I added this as issue 10016 to the new tracker.

Begin forwarded message:

From: David Gorisek <[hidden email]>
Subject: Re: Pharo and scaled decimals

Hello all,

I am testing Pharo and I have noticed that the Pharo compiler does not treat ScaledDecimals the same way they are treated in other Smalltalk dialects (e.g. VW, VAST, Dolphin, STX, etc.).

For example the following is a valid code representing an instance of ScaledDecimal/FixedPoint in all other dialect.

1.0s  + 2.0s

In Phare the code above wont compile, it has to be written as:

1.0s1 + 2.0s1

So I have made the following quick change to make Pharo compatible with other Smalltalk dialects. Maybe this change could be included in the next version of Pharo?

SqNumberParser>>#readScale
    "read the scale if any (stored in instVar).
    Answer true if found, answer false if none.
    If scale letter is not followed by a digit, this is not considered as an error.
    Scales are always read in base 10, though i do not see why..."

    scale := 0.
    sourceStream atEnd
        ifTrue: [ ^ false ].
    (sourceStream peekFor: $s)
        ifFalse: [ ^ false ].
    scale := self nextUnsignedIntegerOrNilBase: 10.
    scale
        ifNil: [
            scale := 0.
            (sourceStream peek ifNil: [false] ifNotNil: [ :nextChar | nextChar isLetter])
                ifTrue: [
                    sourceStream skip: -1.    "ungobble the s"
                    ^ false ]
                ifFalse: [ ^ true ] ].
    ^ true










--

~~Dr. Jannik Laval~~
École des Mines de Douai
Enseignant-chercheur
http://www.jannik-laval.eu

Reply | Threaded
Open this post in threaded view
|

Re: Fwd: Pharo and scaled decimals

Marcus Denker-4

On Mar 14, 2013, at 9:48 AM, jannik laval <[hidden email]> wrote:

Hi,
Should we already use the new tracker ?


I don't know. But I don't want to do it twice….

Is it possible to update the page: http://www.pharo-project.org/community/issue-tracking
It redirect to the google code issue tracker.

Jannik

2013/3/14 Marcus Denker <[hidden email]>
I added this as issue 10016 to the new tracker.

Begin forwarded message:

From: David Gorisek <[hidden email]>
Subject: Re: Pharo and scaled decimals

Hello all,

I am testing Pharo and I have noticed that the Pharo compiler does not treat ScaledDecimals the same way they are treated in other Smalltalk dialects (e.g. VW, VAST, Dolphin, STX, etc.).

For example the following is a valid code representing an instance of ScaledDecimal/FixedPoint in all other dialect.

1.0s  + 2.0s

In Phare the code above wont compile, it has to be written as:

1.0s1 + 2.0s1

So I have made the following quick change to make Pharo compatible with other Smalltalk dialects. Maybe this change could be included in the next version of Pharo?

SqNumberParser>>#readScale
    "read the scale if any (stored in instVar).
    Answer true if found, answer false if none.
    If scale letter is not followed by a digit, this is not considered as an error.
    Scales are always read in base 10, though i do not see why..."

    scale := 0.
    sourceStream atEnd
        ifTrue: [ ^ false ].
    (sourceStream peekFor: $s)
        ifFalse: [ ^ false ].
    scale := self nextUnsignedIntegerOrNilBase: 10.
    scale
        ifNil: [
            scale := 0.
            (sourceStream peek ifNil: [false] ifNotNil: [ :nextChar | nextChar isLetter])
                ifTrue: [
                    sourceStream skip: -1.    "ungobble the s"
                    ^ false ]
                ifFalse: [ ^ true ] ].
    ^ true










--

~~Dr. Jannik Laval~~
École des Mines de Douai
Enseignant-chercheur
http://www.jannik-laval.eu