Interesting expression...

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

Interesting expression...

Igor Stasenko
displayScannerFor: para foreground: foreColor background: backColor
ignoreColorChanges: shadowMode
        "Fixed to answer a MultiDisplayScanner when the paragraph is any kind of
        MultiNewParagraph (rather than an instance of the one class) or the paragraph
        text string is a WideString."

        ((para isKindOf: MultiNewParagraph) or: [para text string isByteString
                        or: [para text string isWideString]])



this one is quite interesting, for what kind of strings in pharo a
given expression yields false?

 string isByteString or: [ string isWideString]

?


i think this code could be rewritten to

true ifTrue: [
 ...

].


--
Best regards,
Igor Stasenko.

Reply | Threaded
Open this post in threaded view
|

Re: Interesting expression...

Marcus Denker-4

On Sep 19, 2011, at 5:28 PM, Igor Stasenko wrote:

> displayScannerFor: para foreground: foreColor background: backColor
> ignoreColorChanges: shadowMode
> "Fixed to answer a MultiDisplayScanner when the paragraph is any kind of
> MultiNewParagraph (rather than an instance of the one class) or the paragraph
> text string is a WideString."
>
> ((para isKindOf: MultiNewParagraph) or: [para text string isByteString
> or: [para text string isWideString]])
>
>
>
> this one is quite interesting, for what kind of strings in pharo a
> given expression yields false?
>
> string isByteString or: [ string isWideString]
>
> ?
>
>
> i think this code could be rewritten to
>
> true ifTrue: [
> ...
>
> ].


In wise pre-cognition, this was  fixed in 1.4 last weekend :-)


--
Marcus Denker -- http://marcusdenker.de


Reply | Threaded
Open this post in threaded view
|

Re: Interesting expression...

csrabak
In reply to this post by Igor Stasenko
Igor,

I think you've half reason about the quality of the test, but in a dynamic language like Smalltalk there is no warranty string wouldn't be anything else than a String. . .
 



Em 19/09/2011 12:28, Igor Stasenko < [hidden email] > escreveu:
displayScannerFor: para foreground: foreColor background: backColor
ignoreColorChanges: shadowMode
 "Fixed to answer a MultiDisplayScanner when the paragraph is any kind of
 MultiNewParagraph (rather than an instance of the one class) or the paragraph
 text string is a WideString."

 ((para isKindOf: MultiNewParagraph) or: [para text string isByteString
 or: [para text string isWideString]])



this one is quite interesting, for what kind of strings in pharo a
given expression yields false?

 string isByteString or: [ string isWideString]

?


i think this code could be rewritten to

true ifTrue: [
 ...

].


--
Best regards,
Igor Stasenko.



Reply | Threaded
Open this post in threaded view
|

Re: Interesting expression...

Igor Stasenko
On 20 September 2011 18:52,  <[hidden email]> wrote:
> Igor,
>
> I think you've half reason about the quality of the test, but in a dynamic language like Smalltalk there is no warranty string wouldn't be anything else than a String. . .
>

in theory , yes. But in practice it is different.

The text displaying code is extremely "practical" one. Because it
should be fast.
And i don't see reason why it should accept anything else than strings there.



>
> Em 19/09/2011 12:28, Igor Stasenko < [hidden email] > escreveu:
> displayScannerFor: para foreground: foreColor background: backColor
> ignoreColorChanges: shadowMode
>  "Fixed to answer a MultiDisplayScanner when the paragraph is any kind of
>  MultiNewParagraph (rather than an instance of the one class) or the paragraph
>  text string is a WideString."
>
>  ((para isKindOf: MultiNewParagraph) or: [para text string isByteString
>  or: [para text string isWideString]])
>
>
>
> this one is quite interesting, for what kind of strings in pharo a
> given expression yields false?
>
>  string isByteString or: [ string isWideString]
>
> ?
>
>
> i think this code could be rewritten to
>
> true ifTrue: [
>  ...
>
> ].
>
>
> --
> Best regards,
> Igor Stasenko.
>
>
>
>



--
Best regards,
Igor Stasenko.

Reply | Threaded
Open this post in threaded view
|

Re: Interesting expression...

Henrik Sperre Johansen
On 20.09.2011 19:18, Igor Stasenko wrote:

> On 20 September 2011 18:52,<[hidden email]>  wrote:
>> Igor,
>>
>> I think you've half reason about the quality of the test, but in a dynamic language like Smalltalk there is no warranty string wouldn't be anything else than a String. . .
>>
> in theory , yes. But in practice it is different.
>
> The text displaying code is extremely "practical" one. Because it
> should be fast.
> And i don't see reason why it should accept anything else than strings there.
IIRC, I've been bitten in the past with Text instances being passed to
the rendering methods, not sure if the same holds true for the scanner...

Cheers,
Henry

Reply | Threaded
Open this post in threaded view
|

Re: Interesting expression...

Stephan Eggermont-3
In reply to this post by Igor Stasenko
> ((para isKindOf: MultiNewParagraph) or: [para text string isByteString
> or: [para text string isWideString]])

If you want to be able to handle large texts with nice (LaTeX-like) line breaking
we'll probably need some different String implementations. I don't know how
far MultiNewParagraph scales.

Stephan