Pharo-dev
By thread
pharo-dev@lists.pharo.org
By month
Messages by month
- ----- 2026 -----
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
October 2010
- 130 participants
- 1604 messages
Re: [Pharo-project] bad bracket autocompletion in Pharo Core 1.2
by Guillermo Polito
Here is the piece of code that's behaving weird
TextEditor>>dispatchOn:
...
...
char := aKeyboardEvent keyCharacter.
openers := '([{'.
closers := ')]}'.
( closers includes: char) ifTrue: [ self blinkPrevParen: char ].
result := self normalCharacter: aKeyboardEvent.
(self class autoEnclose and: [ openers includes: char ]) not ifTrue:
[ ^ result ].
suffix := closers at: (openers indexOf: char).
paragraph text append: suffix asString.
self moveCursor: [ : position | position ] forward: true
specialBlock: [ : pos | "no special behavior" ] event: aKeyboardEvent .
self userHasEdited.
-------------------------------------
So, if I evaluate "TextEditor autoEnclose: false", it is stops behaving like
that :)
What should be the desired behavior? Having it configurable as it is today
but fix the strange bracket adding? remove this behavior?
I can't find now how ParagraphEditor did this.
Guille
On Wed, Oct 6, 2010 at 10:34 PM, Guillermo Polito <guillermopolito(a)gmail.com
> wrote:
> Yes, the issue can be reduced to:
>
> open parenthesis (or brackets), then something else (anywhere in the
> editor).
>
> 2010/10/6 Mariano Martinez Peck <marianopeck(a)gmail.com>
>
> I detected a similar problem:
>>
>> once you type an opening parenthesis, and then something else, it adds a
>> new one at the END of the code
>>
>> check http://code.google.com/p/pharo/issues/detail?id=2939
>>
>> 2010/10/6 Guillermo Polito <guillermopolito(a)gmail.com>
>>
>>> http://code.google.com/p/pharo/issues/detail?id=3069
>>>
>>> if you type:
>>>
>>> [] -> []]
>>>
>>> () -> ())
>>>
>>> {} -> {}}
>>>
>>>
>>>
>>> Bye!
>>>
>>> _______________________________________________
>>> Pharo-project mailing list
>>> Pharo-project(a)lists.gforge.inria.fr
>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>>
>>
>>
>> _______________________________________________
>> Pharo-project mailing list
>> Pharo-project(a)lists.gforge.inria.fr
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>
>
>
Oct. 9, 2010
Re: [Pharo-project] Strange code replacement when prompting unknown selector
by Guillermo Polito
The problem seems to be between *TextEditor>>correctFrom:to:with:* and *
Parser>>substituteWord:wordInterval:offset:*
The TextEditor isn't using well the selection offset to calculate the
replacement, and the parser is sending an interval that's not the one that
the Editor must replace.
I think the right place to put this is the Editor, but behind another
message like replaceInSelectionFrom:to:with:
What do you think?
Guille
On Wed, Oct 6, 2010 at 6:33 PM, Guillermo Polito
<guillermopolito(a)gmail.com>wrote:
> http://code.google.com/p/pharo/issues/detail?id=3070
>
> Cheers!
> Guille
>
Oct. 9, 2010
Re: [Pharo-project] MicroSqueak [was System Tracer]
by Eliot Miranda
Hi All,
I'm please to let you know that John Maloney has published his
MicroSqueak code on his website under the MIT license.
http://web.media.mit.edu/~jmaloney/microsqueak/
<http://web.media.mit.edu/~jmaloney/microsqueak/>Apologies for the premature
posting. We can get down to business now. Again huge thanks to John for
this code.
On Thu, Oct 7, 2010 at 10:26 AM, Eliot Miranda <eliot.miranda(a)gmail.com>wrote:
> Hi All,
>
>
> turns out John does not want this code released, so please can you
> destroy any and all copies? Also, who do I have to talk to to get the
> archive message, with attachments, destroyed?
>
> Apologies to all, I've f***ed up badly here.
>
> Eliot
>
>
> On Wed, Oct 6, 2010 at 4:22 PM, Eliot Miranda <eliot.miranda(a)gmail.com>wrote:
>
>> FInd attached. You want MicroSqueak-colonequal.st and the various
>> MSqueak-.st files. This produces a 57k image. John's also given me a 2.0
>> development image which will run on a 3.8 VM. Let me know if you want that.
>> For me this is a proof of concept. What's needed is to define a headless
>> core that contains the compiler, good error reporting to standard out, the
>> core collection and numeric libraries and file support. Then we try and
>> load packages into it and build up a headful image.
>>
>> On Wed, Oct 6, 2010 at 3:03 PM, Stéphane Ducasse <
>> stephane.ducasse(a)inria.fr> wrote:
>>
>>>
>>> On Oct 6, 2010, at 7:18 PM, Eliot Miranda wrote:
>>>
>>> >
>>> >
>>> > On Wed, Oct 6, 2010 at 7:31 AM, Stéphane Ducasse <
>>> stephane.ducasse(a)inria.fr> wrote:
>>> > generate a new image.
>>> >
>>> > But that's not what it does.
>>>
>>> Yes I know gnerates = clone in my mail.
>>>
>>> > t merely clones an image, which is a long way form building an image
>>> form source. *That*'s a useful project. John Maloney's lovely MicroSqueak
>>> is a good starting point for ideas (basically have a copy of a kernel subset
>>> of the system in a namespace and generate a fresh image from that).
>>>
>>> Do you have a pointer on the code of john. We are looking at bootstrap
>>> code right now.
>>>
>>> >
>>> > On Oct 6, 2010, at 2:23 PM, Alexandre Bergel wrote:
>>> >
>>> > > Hi!
>>> > >
>>> > > What do you want to achieve?
>>> > >
>>> > > Cheers,
>>> > > Alexandre
>>> > >
>>> > >
>>> > > On 6 Oct 2010, at 05:36, Gabriel Hernán Barbuto wrote:
>>> > >
>>> > >> Hi
>>> > >>
>>> > >> Does anyone know where I can find the system tracer that is
>>> currently
>>> > >> in use in Pharo?
>>> > >>
>>> > >> Bests
>>> > >> Gabriel
>>> > >>
>>> > >> _______________________________________________
>>> > >> Pharo-project mailing list
>>> > >> Pharo-project(a)lists.gforge.inria.fr
>>> > >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>> > >
>>> > > --
>>> > > _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
>>> > > Alexandre Bergel http://www.bergel.eu
>>> > > ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
>>> > >
>>> > >
>>> > >
>>> > >
>>> > >
>>> > >
>>> > > _______________________________________________
>>> > > Pharo-project mailing list
>>> > > Pharo-project(a)lists.gforge.inria.fr
>>> > > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>> >
>>> >
>>> > _______________________________________________
>>> > Pharo-project mailing list
>>> > Pharo-project(a)lists.gforge.inria.fr
>>> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>> >
>>> > _______________________________________________
>>> > Pharo-project mailing list
>>> > Pharo-project(a)lists.gforge.inria.fr
>>> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>>
>>>
>>> _______________________________________________
>>> Pharo-project mailing list
>>> Pharo-project(a)lists.gforge.inria.fr
>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>>
>>
>>
>
Oct. 9, 2010
Re: [Pharo-project] #hasBindingThatBeginsWith:, Shout, E/OCompletion (fwd)
by Miguel Cobá
El vie, 08-10-2010 a las 23:48 +0200, Levente Uzonyi escribió:
> I accidentally sent this to the pharo-users list...
>
> ---------- Forwarded message ----------
> Date: Fri, 8 Oct 2010 23:14:02 +0200 (CEST)
> From: Levente Uzonyi <leves(a)elte.hu>
> To: squeak-dev(a)lists.squeakfoundation.org, pharo-users(a)lists.gforge.inria.fr
> Subject: #hasBindingThatBeginsWith:, Shout, E/OCompletion
>
> Hi folks,
>
>
> there's a method called #hasBindingThatBeginsWith: which seems to be used
> only by Shout. If that's true, then it would be better to add it to the
> Shout/ShoutCore package if possible.
> Also this method is responsible for the slowdown of Shout's parser when there
> are undefined variables in the code. Actually only SystemDictionary
> >> #hasBindingsThatBeginsWith: is responsible for the slowdown which uses
> Dictionary's implementation which checks all keys.
> There's already an issue on Pharo's tracker (with some useful, but with
> some wrong info too): http://code.google.com/p/pharo/issues/detail?id=1452 .
> The slowdown affects E/OCompletion more, because those invoke Shout's parser
> after every keystroke, while Shout uses a background process for parsing.
> I propose two possible solutions here:
>
> 1) Add the following method (+2-3 other, see below):
>
> SystemDictionary >> hasBindingThatBeginsWith: aString
>
> | className |
> aString isEmpty ifTrue: [ ^false ].
> (self class fastBindingPrefixSearch and: [
> aString first isLowercase ])
> ifTrue: [ ^false ].
> className := self classNames
> findBinary: [ :element |
> (element beginsWith: aString)
> ifTrue: [ 0 ]
> ifFalse: [
> aString < element
> ifTrue: [ -1 ]
> ifFalse: [ 1 ] ] ]
> ifNone: nil.
> className ifNotNil: [ ^true ].
> ^super hasBindingThatBeginsWith: aString
>
>
> How does it work?
> There are two optimizations. The first checks if the argument's first letter is
> lowercase. If it's a lowercase letter, then it returns false instead of
> checking the dictionary. This is the most common case when you're typing
> methods with undefined local/instance variables. Since this optimization breaks
> Shout's highlighting when the argument is a prefix of a global that begins with
> a lowercase letter, there's a boolean preference/setting that enables/disables
> this optimization (SystemDictionary class >> #fastBindingPrefixSearch).
> The other optimization uses binary search on SystemDictionary's cached class
> names, which is a SortedCollection with all the classnames in the system. This
> helps when you're typing the name of an existing class. Since Shout uses a
> background process, this is mostly useful for E/OCompletion. When none of these
> optimizations are usable, the method simply falls back to scanning all keys.
>
> Pros:
> - very simple addition
> - covers the most common cases
> Cons:
> - it doesn't work for all cases
> - it breaks Shout highlighting a bit
>
> 2) Add a new instance variable to SystemDictionary to hold the name of
> non-class globals, use binary search on both sorted collections:
>
> SystemDictionary >> hasBindingThatBeginsWith: aString
>
> | name searchBlock |
> searchBlock := [ :element |
> (element beginsWith: aString)
> ifTrue: [ 0 ]
> ifFalse: [
> aString < element
> ifTrue: [ -1 ]
> ifFalse: [ 1 ] ] ].
> name := self classNames
> findBinary: searchBlock
> ifNone: nil.
> name ifNotNil: [ ^true ].
> name := self nonClassNames
> findBinary: searchBlock
> ifNone: nil.
> ^name notNil
>
> (for the rest see System-ul.384 in the Inbox for Squeak and
> http://leves.web.elte.hu/squeak/SystemDictionary.ul.1.cs for Pharo)
>
> How does it work?
> It's just two binary search, one on the class names and one on the non-clas
> names. This covers all globals (except those which are not in memory (Squeak
> only)).
>
> Pros:
> - covers all cases with good performance
> - the new cache can be used to speed up other methods (like #allTraits)
> Cons:
> - modifies SystemDictionary
>
> I'd go with the second solution. What do you think?
+1 to the second option with two caches for class and non class names.
>
>
> Cheers,
> Levente
>
> _______________________________________________
> Pharo-project mailing list
> Pharo-project(a)lists.gforge.inria.fr
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
--
Miguel Cobá
http://miguel.leugim.com.mx
Oct. 9, 2010
Re: [Pharo-project] XTream was Re: Ocean (was Re: Less plugins, more Smalltalk code!)
by mkobetic@gmail.com
"Nicolas Cellier"<nicolas.cellier.aka.nice(a)gmail.com> wrote:
> More example than the site http://code.google.com/p/xtreams/ ? If so, I'm interested.
Not more, but different. For example I'm quite fond of the Morse code decoding example:
('. ... ..- --. -... .- .-. -.-. . .-.. --- -. .- -- -- -..- ' reading
transforming: [ :in :out || node beep |
node := MorseTree.
[ beep := in get.
beep = Character space
] whileFalse: [
node := beep = $.
ifTrue: [ node at: 3 ]
ifFalse: [ node at: 2 ] ].
out put: node first ]
) rest
Where MorseTree is (http://en.wikipedia.org/wiki/File:Morse_code_tree3.png) encoded as nested three element arrays: #($ ($T ($M ($O) ($G ($Q) ($Z))) ($N ($K ($Y) ($C)) ($D ($X) ($B)))) ($E ($A ($W ($J) ($P)) ($R () ($L))) ($I ($U () ($F)) ($S ($V) ($H)))))
Anyway, I'll send you the PDF directly.
> Yes, that makes sense, what I call the Xtreme approach... Less confusion.
> However it would be wonderfull to get feedback from average programmer
> about this on real application.
Not sure what you meant.
> Maybe this will be a matter of adding one missing convenient message or two...
Yes we can certainly add a package that implements most (maybe all) of the classic API as an extension. But I'd rather keep the Core clean and minimal. This way you have the choice of both.
> Of course the best option is to share. Though I don't think Xtream was
> developped with portability as main goal, it's not sure it has so many
> external dependencies.
Yes, we didn't spend much time thinking about portability so far. We rewrote the whole thing bottom up several times trying to get the design right, so we didn't want to be distracted by other concerns. That doesn't mean that we can't focus on that now assuming we're reasonably happy with current design. I don't think there are particular dependencies that are critical to make Xtreams work in general. As long as we can preserve the efficiency, we can certainly make necessary changes.
That said, I think we'll just have dialect specific versions of some of the packages. Hopefully Xtreams-Core can be fully portable. Xtreams-Terminals are likely going to be dialect specific. Xtreams-Transforms could probably be portable if we move the VW specific encoding stuff elsewhere. Maybe it can just go into Xtreams-Xtras. It was nice to have the encodings with the core transforms but until we have portable encoders we can just maintain those in dialect specific packages. Something like that.
> Is there a tool to identify the dependency on classes outside the package in VW ?
Yes there is a tab in the browser that autocomputes prerequisites and a menu option that gives you depenedents if you want the other direction.
> We know in advance a few concerning the system, File & Sockets, DLLCC, compression...
Yes, I would expect each dialect to have it's own implementation of most of the terminal streams. It might be possible to share some of those, e.g. collection or buffer streams, but given that different dialects have different ways to deal with them efficiently, we may want to have dialect specific implementations anyway. Ultimately, it's fine if different dialects support different set of terminals. There will probably be some that we want everywhere, but maybe it would be great to be able to stream over some Morphs in Squeak or something such. If that's useful, there's no reason not to do it because VW doesn't have Morphic. Anyway, the point is not all the code has to be portable, we can try to share as much as is feasible and have dialect specific implementation of the rest.
So at least initially, I'd focus on getting a portable Core and Transforms, with dialect specific Terminals, and we can think about stuff in Xtras later.
> Then, there is the question of using Exception handling or not. In
> Squeak, this isn't going to be a matter of compatibility (though the
> difference might be subtle), rather a matter of efficiency.
> However, Incomplete is a corner stone of Xtream implementation if I
> understand correctly...
> Squeak is not using EndOfStream
> http://bugs.squeak.org/view.php?id=6755 and some of the efficiency
> reasons are there
> http://lists.squeakfoundation.org/pipermail/squeak-dev/2007-November/122434…
>
> On the other hand, the endOfStreamAction of Squeak_Xtream is pleasant
> at first, but hard to handle across wrappers. I don't yet have an
> answer whether it scales on a more complete xtream library or not
> (thinking of blocking streams...).
Yes, this one is tricky. Exceptions cost something in VW as well, so you need to be reasonably prudent with them. As Michael mentioned we've made some serious adjustments in Xtreams earlier this year to avoid triggering Incomplete internally if we could get by without it. See
http://www.cincomsmalltalk.com/userblogs/mls/blogView?entry=3445952077
http://www.cincomsmalltalk.com/userblogs/mls/blogView?entry=3448891140
But I think your original argument that in common case the exception should not be triggered frequently is valid. Certainly if you write a micro-benchmark which stacks the odds the other way it will show, but as they say micro-benchmarks are not applications. At the same time consider the cost of not using an exception. Exception allows me to write my algorithm without worrying about the end of stream if I wrap the whole thing in a handler. And the handler is normally located in the right place to handle the end of stream. Without the exception you'll have to add end checks to every single read call of the algorithm. I'm not talking about runtime cost here, I'm talking code complexity. And I don't see how an "end of stream block" makes this much better. The exception allows me to get out of the main body of the algorithm at any of its points, and if the handler exits, the main block gets unwound cleanly. How do I do that with a block that I set on the stream instance? You'd have to carefully structure the code so that the algorithm body is in a method of its own and then there's a dedicated wrapper method around that so that the block can use a side-ways return to exit the method. That is some pretty hideous boiler-plate code, if you ask me.f
So, I'm not saying that exception costs are negligible, but there are often ways to minimize them in specific scenarios, often via well designed APIs and patterns (and proper internal implementation). As Michael's posts above show, we were able to match and beat the speed of regular streams in the example without sacrificing the API. At the same time Squeak is getting faster, so I'm not at all convinced that the slow-down factor always does and always will trump the other costs. In fact I feel that it's more often than not the other way around, that the slow down can be made sufficiently small so that it does pay off in terms of code complexity. Maybe some things will always want a stream that doesn't trigger exceptions, but that doesn't mean most things are better off that way. That's just my opinion.
Anyway, so far we've been doing quite well in terms of performance without sacrificing exceptions. I'd say let's see if we can keep that track record on Squeak as well. If we find out that it's just not good enough in general case, maybe we'll re-evaluate then. But at this point I'm not convinced that we need to drop the exception to keep Xtreams reasonably usable.
Martin
Oct. 8, 2010
Re: [Pharo-project] [vwnc] XTream was Re: Ocean (was Re: Less plugins, more Smalltalk code!)
by Nicolas Cellier
Resent, reply to all...
2010/10/9 Michael Lucas-Smith <michael.lucassmith(a)gmail.com>:
>>
>> Hehe, I've got the feeling to surf on your hard work with low investment ;)
>> Xtream ideas should definitly continue to attract. J'espère que la
>> mayonnaise va prendre.
>> Of course the best option is to share. Though I don't think Xtream was
>> developped with portability as main goal, it's not sure it has so many
>> external dependencies.
>> Is there a tool to identify the dependency on classes outside the
>> package in VW ?
>> We know in advance a few concerning the system, File & Sockets, DLLCC,
>> compression...
>> With good package delimitation, that can be worked out.
>
> We divided the Xtreams packages up with this in mind. The Core should be portable, the Terminals are not -- they must be implemented for each platform because they're the ones that use the platform specific objects.
>
I'm browsing VW right now, at first sight there are not so many
uncompatibilities in core, should be solved easily
Incomplete>>#raise could be added (#signal in Squeak)
#copyEmpty: could be an extension
#isFixedArgument not existing in Squeak (external heap notion exists though)
Lack of namespace in Squeak shall force use of a prefix (XT ?).
Some terminals are generic and should port easily too:
BlockClosure/Buffer/Collection
For File, assuming they are non blocking, we can arrange a quick hack.
For transforms, the StreamEncoder does not exist in Squeak (better not
use existing Multilingual, a rewrite will be cleaner).
>> The problem with Squeak is that we don't have a good File library (non
>> blocking). The good point with Xtream is that we don't need that many
>> primitives.
>> And last good point is the huge effort you made to coverage tests...
>> That should ease porting.
>
> It's okay if not all terminals and transformation are supported on every platform. We could create a capabilities grid for the different ports to show what can and can't be done.
>
>>
>> Then, there is the question of using Exception handling or not. In
>> Squeak, this isn't going to be a matter of compatibility (though the
>> difference might be subtle), rather a matter of efficiency.
>> However, Incomplete is a corner stone of Xtream implementation if I
>> understand correctly...
>> Squeak is not using EndOfStream
>> http://bugs.squeak.org/view.php?id=6755 and some of the efficiency
>> reasons are there
>> http://lists.squeakfoundation.org/pipermail/squeak-dev/2007-November/122434…
>
> Even in VisualWorks Exceptions are expensive. We went to great lengths to make sure the exception mechanism did not fire constantly. We spent several agonizing weeks studying the effects of our implementation on garbage generation and efficiency until we finally arrived at the design we have now. The biggest problems were with substreaming which we eventually solved.
>
> Michael
The simplest thing is just to port a few classes then bench... That's
worth a try.
Nicolas
Oct. 8, 2010
[Pharo-project] #hasBindingThatBeginsWith:, Shout, E/OCompletion (fwd)
by Levente Uzonyi
I accidentally sent this to the pharo-users list...
---------- Forwarded message ----------
Date: Fri, 8 Oct 2010 23:14:02 +0200 (CEST)
From: Levente Uzonyi <leves(a)elte.hu>
To: squeak-dev(a)lists.squeakfoundation.org, pharo-users(a)lists.gforge.inria.fr
Subject: #hasBindingThatBeginsWith:, Shout, E/OCompletion
Hi folks,
there's a method called #hasBindingThatBeginsWith: which seems to be used
only by Shout. If that's true, then it would be better to add it to the
Shout/ShoutCore package if possible.
Also this method is responsible for the slowdown of Shout's parser when there
are undefined variables in the code. Actually only SystemDictionary
>> #hasBindingsThatBeginsWith: is responsible for the slowdown which uses
Dictionary's implementation which checks all keys.
There's already an issue on Pharo's tracker (with some useful, but with
some wrong info too): http://code.google.com/p/pharo/issues/detail?id=1452 .
The slowdown affects E/OCompletion more, because those invoke Shout's parser
after every keystroke, while Shout uses a background process for parsing.
I propose two possible solutions here:
1) Add the following method (+2-3 other, see below):
SystemDictionary >> hasBindingThatBeginsWith: aString
| className |
aString isEmpty ifTrue: [ ^false ].
(self class fastBindingPrefixSearch and: [
aString first isLowercase ])
ifTrue: [ ^false ].
className := self classNames
findBinary: [ :element |
(element beginsWith: aString)
ifTrue: [ 0 ]
ifFalse: [
aString < element
ifTrue: [ -1 ]
ifFalse: [ 1 ] ] ]
ifNone: nil.
className ifNotNil: [ ^true ].
^super hasBindingThatBeginsWith: aString
How does it work?
There are two optimizations. The first checks if the argument's first letter is
lowercase. If it's a lowercase letter, then it returns false instead of
checking the dictionary. This is the most common case when you're typing
methods with undefined local/instance variables. Since this optimization breaks
Shout's highlighting when the argument is a prefix of a global that begins with
a lowercase letter, there's a boolean preference/setting that enables/disables
this optimization (SystemDictionary class >> #fastBindingPrefixSearch).
The other optimization uses binary search on SystemDictionary's cached class
names, which is a SortedCollection with all the classnames in the system. This
helps when you're typing the name of an existing class. Since Shout uses a
background process, this is mostly useful for E/OCompletion. When none of these
optimizations are usable, the method simply falls back to scanning all keys.
Pros:
- very simple addition
- covers the most common cases
Cons:
- it doesn't work for all cases
- it breaks Shout highlighting a bit
2) Add a new instance variable to SystemDictionary to hold the name of
non-class globals, use binary search on both sorted collections:
SystemDictionary >> hasBindingThatBeginsWith: aString
| name searchBlock |
searchBlock := [ :element |
(element beginsWith: aString)
ifTrue: [ 0 ]
ifFalse: [
aString < element
ifTrue: [ -1 ]
ifFalse: [ 1 ] ] ].
name := self classNames
findBinary: searchBlock
ifNone: nil.
name ifNotNil: [ ^true ].
name := self nonClassNames
findBinary: searchBlock
ifNone: nil.
^name notNil
(for the rest see System-ul.384 in the Inbox for Squeak and
http://leves.web.elte.hu/squeak/SystemDictionary.ul.1.cs for Pharo)
How does it work?
It's just two binary search, one on the class names and one on the non-clas
names. This covers all globals (except those which are not in memory (Squeak
only)).
Pros:
- covers all cases with good performance
- the new cache can be used to speed up other methods (like #allTraits)
Cons:
- modifies SystemDictionary
I'd go with the second solution. What do you think?
Cheers,
Levente
Oct. 8, 2010
Re: [Pharo-project] XTream was Re: Re: Ocean (was Re: Less plugins, more Smalltalk code!)
by Nicolas Cellier
2010/10/8 Igor Stasenko <siguctua(a)gmail.com>:
> On 8 October 2010 23:13, Nicolas Cellier
> <nicolas.cellier.aka.nice(a)gmail.com> wrote:
>> 2010/10/8 Igor Stasenko <siguctua(a)gmail.com>:
>>> I recalled one detail:
>>>
>>> VW Xtreams are composable from the beginning, its a core stream feature.
>>> Not like ours, which require wrappers, which i added (and thus a lot
>>> of clutter on proxying message sends).
>>>
>>> :)
>>>
>>>
>>
>> I still fail to see the difference. Squeak_XTream are composable from
>> the beginning, ReadXtream all have a source, WriteXtream all have a
>> destination, and most of the subclasses fill those ivars with another
>> XTream.
>>
>> VW_XTream.ReadStream>> on: aSource
>> Â Â source := aSource
>>
>> Squeak_Xtream.ReadXtream>>source: anObject
>> Â Â "Set the source of this stream"
>>
>> Â Â source := anObject
>>
>> Or is it just a question of naming ?
>> I adopted #source:, simply because #on: is harder to trace (too many
>> implementors).
>> Maybe the difference is just a convenient wrapping message or two
>> missing in Squeak_XTream.
>>
>> The wrapper class you added are indeed unecessary in both
>> Squeak_XTream and VW_Xtream. I should have given more feedback to you.
>>
>> If you want to look at differences between the two implementation,
>> rather look at VW_Xtream.Buffer and subclasses.
>> Also look at use of Exception handling in VW_Xtream (users of Incomplete).
>> Don't look number of classes & methods, I obviously don't scale ;)
>> Having only nights and week-ends left for programming, I just don't
>> want to compete ;)
>>
>
> One of ideas, i like in VW Xtreams is an ease of creating transforming streams:
>
> Â Â Â Â "hex encoding: #[0 1 2 ... 255] -> '000102...FF' "
> Â Â Â Â bytes := ByteArray withAll: (0 to: 255).
> Â Â Â Â digits := '0123456789ABCDEF'.
> Â Â Â Â byte2hex := [ :in :out || byte |
> Â Â Â Â Â Â Â Â byte := in get.
> Â Â Â Â Â Â Â Â out put: (digits at: (byte bitShift: -4) + 1).
> Â Â Â Â Â Â Â Â out put: (digits at: (byte bitAnd: 15) + 1) ].
> Â Â Â Â (bytes reading transforming: byte2hex)
> Â Â Â Â Â Â Â Â contentsSpecies: String;
> Â Â Â Â Â Â Â Â rest
>
>
> here
> bytes reading, answers a reader xtream
> then by sending #transforming: aBlock
> you wrap this stream with transforming stream, which using a block for
> transformations.
> note, that block takes in and out arguments, which are streams
> instead of taking a single argument, like a next element read from
> source stream.
> In this way you can control transformation in any way you like:
> - read N elements from source and produce M elements as output.
>
> This is very powerful. Simplest example , which comes in mind is our
> beloved UTF8 reader
> - it may read 1, 2, 3 or 4 bytes from source to produce 1 character at output.
>
> What i like in it, that you don't need to create a separate class for
> each kind of transformation,
> since you can simply construct it on the fly using blocks, like:
>
> Xtream>>decodeUTF8
> Â ^ self transforming: [:in :out |
> Â byte := Â in get.
> Â .... (utf 8 decoding logic )
> Â out put: result ]
>
Yes, this is a very nice generalization indeed.
The Squeak_XTream-Parallel package has a totally screwed
implementation of it. It's less simple than it sounds ;)
Nicolas
>
>> Nicolas
>>
>>>
>>> --
>>> Best regards,
>>> Igor Stasenko AKA sig.
>>>
>>> _______________________________________________
>>> Pharo-project mailing list
>>> Pharo-project(a)lists.gforge.inria.fr
>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>>
>>
>> _______________________________________________
>> Pharo-project mailing list
>> Pharo-project(a)lists.gforge.inria.fr
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>
>
>
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>
> _______________________________________________
> Pharo-project mailing list
> Pharo-project(a)lists.gforge.inria.fr
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Oct. 8, 2010
Re: [Pharo-project] XTream was Re: Re: Ocean (was Re: Less plugins, more Smalltalk code!)
by Igor Stasenko
On 8 October 2010 23:13, Nicolas Cellier
<nicolas.cellier.aka.nice(a)gmail.com> wrote:
> 2010/10/8 Igor Stasenko <siguctua(a)gmail.com>:
>> I recalled one detail:
>>
>> VW Xtreams are composable from the beginning, its a core stream feature.
>> Not like ours, which require wrappers, which i added (and thus a lot
>> of clutter on proxying message sends).
>>
>> :)
>>
>>
>
> I still fail to see the difference. Squeak_XTream are composable from
> the beginning, ReadXtream all have a source, WriteXtream all have a
> destination, and most of the subclasses fill those ivars with another
> XTream.
>
> VW_XTream.ReadStream>> on: aSource
> Â Â source := aSource
>
> Squeak_Xtream.ReadXtream>>source: anObject
> Â Â "Set the source of this stream"
>
> Â Â source := anObject
>
> Or is it just a question of naming ?
> I adopted #source:, simply because #on: is harder to trace (too many
> implementors).
> Maybe the difference is just a convenient wrapping message or two
> missing in Squeak_XTream.
>
> The wrapper class you added are indeed unecessary in both
> Squeak_XTream and VW_Xtream. I should have given more feedback to you.
>
> If you want to look at differences between the two implementation,
> rather look at VW_Xtream.Buffer and subclasses.
> Also look at use of Exception handling in VW_Xtream (users of Incomplete).
> Don't look number of classes & methods, I obviously don't scale ;)
> Having only nights and week-ends left for programming, I just don't
> want to compete ;)
>
One of ideas, i like in VW Xtreams is an ease of creating transforming streams:
"hex encoding: #[0 1 2 ... 255] -> '000102...FF' "
bytes := ByteArray withAll: (0 to: 255).
digits := '0123456789ABCDEF'.
byte2hex := [ :in :out || byte |
byte := in get.
out put: (digits at: (byte bitShift: -4) + 1).
out put: (digits at: (byte bitAnd: 15) + 1) ].
(bytes reading transforming: byte2hex)
contentsSpecies: String;
rest
here
bytes reading, answers a reader xtream
then by sending #transforming: aBlock
you wrap this stream with transforming stream, which using a block for
transformations.
note, that block takes in and out arguments, which are streams
instead of taking a single argument, like a next element read from
source stream.
In this way you can control transformation in any way you like:
- read N elements from source and produce M elements as output.
This is very powerful. Simplest example , which comes in mind is our
beloved UTF8 reader
- it may read 1, 2, 3 or 4 bytes from source to produce 1 character at output.
What i like in it, that you don't need to create a separate class for
each kind of transformation,
since you can simply construct it on the fly using blocks, like:
Xtream>>decodeUTF8
^ self transforming: [:in :out |
byte := in get.
.... (utf 8 decoding logic )
out put: result ]
> Nicolas
>
>>
>> --
>> Best regards,
>> Igor Stasenko AKA sig.
>>
>> _______________________________________________
>> Pharo-project mailing list
>> Pharo-project(a)lists.gforge.inria.fr
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>
>
> _______________________________________________
> Pharo-project mailing list
> Pharo-project(a)lists.gforge.inria.fr
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
--
Best regards,
Igor Stasenko AKA sig.
Oct. 8, 2010
Re: [Pharo-project] XTream was Re: Ocean (was Re: Less plugins, more Smalltalk code!)
by Nicolas Cellier
Hi Martin, Michael.
thanks for this feedback, that's usefull.
2010/10/8 <mkobetic(a)gmail.com>:
> I saw this thread on the pharo list and figured that a bit of feedback from Michael and myself might be helpful. Please, forgive the cross-posting, this concerns both dialects and I'd like to make this discussion visible on the VW side as well.
>
> First of all, let me thank everyone for the "xtreamly" positive feedback. It sure feels good to get a thumbs up once in a while. So, thanks!
>
> Since there was a question earlier about availability of my ESUG slides, I'll also add that a rather crude and plain but usable pdf export of those is available on the ESUG slideshare. I'd be happy to forward the pdf to anyone interested as well. It's full of examples and it certainly should be easier to copy those from there than from the video or memory :-).
>
More example than the site http://code.google.com/p/xtreams/ ? If so,
I'm interested.
> As far as the future plans for Xtreams go (at least on VW side), we'd primarily like to validate the design with actual use, and fix any outstanding issues of course. We are certainly open towards collaboration with others on further development or porting efforts. I'd be happy to help sort out any porting issues (at least from the VW side).
>
> Regarding the general direction of the project, we are skeptical about the possibility of maintaining backward compatibility with the classic streams and yet being able to make the kind of changes that we're experimenting with in Xtreams. At this point we believe that the only practical approach is to let them live side by side and let people chose whichever fits better their needs. If Xtreams ever do gain significant acceptance there certainly is a very real possibility that we'll end up having to live with both frameworks, maybe forever. But we don't think there's practical way to somehow evolve the classic streams into something like Xtreams without wreaking havoc.
>
Yes, I think this is even worse in Squeak, because of proliferation of
subclasses. I played with it, but that can't be a transparent
replacement. Rather a huge rewrite (not counting external packages...)
> That's also partly why we took the liberty of changing even the basic APIs. They don't behave quite the same way (intentionally) in a number of cases and given that the two will likely have to coexist in the same context, it might be actually beneficial to make them distinctly different, so that it's clear which one is used where. Anyway, what I'm getting at is that some of the choices we've already made with Xtreams might be hard for us to compromise on, but we can certainly discuss the options. On the other hand, implementation changes that aid portability and don't compromise the basic goals are certainly a fair game. Ideally we'll be able to agree on an arrangement that would allow the project to co-evolve on multiple-dialects without the need to effectively fork the code-base. That would certainly be worth-while and we're definitely interested in trying to achieve that. I'll be at the Smalltalks 2010 conference in november and would be happy to discuss any details if there are people interested in this.
>
Yes, that makes sense, what I call the Xtreme approach... Less confusion.
However it would be wonderfull to get feedback from average programmer
about this on real application.
Maybe this will be a matter of adding one missing convenient message or two...
> Obviously, given the license, people are free to fork the code or start from scratch or whatever and take it in whatever direction they see fit. I just want to make it clear that we are open to collaboration as long as we can agree on general direction. So, no hard feelings Nicolas :-), although we may want to sort out the naming eventually just for the sake of avoiding confusion in the Squeak and Pharo world (if Xtreams ever get traction there).
>
Hehe, I've got the feeling to surf on your hard work with low investment ;)
Xtream ideas should definitly continue to attract. J'espère que la
mayonnaise va prendre.
Of course the best option is to share. Though I don't think Xtream was
developped with portability as main goal, it's not sure it has so many
external dependencies.
Is there a tool to identify the dependency on classes outside the
package in VW ?
We know in advance a few concerning the system, File & Sockets, DLLCC,
compression...
With good package delimitation, that can be worked out.
The problem with Squeak is that we don't have a good File library (non
blocking). The good point with Xtream is that we don't need that many
primitives.
And last good point is the huge effort you made to coverage tests...
That should ease porting.
Then, there is the question of using Exception handling or not. In
Squeak, this isn't going to be a matter of compatibility (though the
difference might be subtle), rather a matter of efficiency.
However, Incomplete is a corner stone of Xtream implementation if I
understand correctly...
Squeak is not using EndOfStream
http://bugs.squeak.org/view.php?id=6755 and some of the efficiency
reasons are there
http://lists.squeakfoundation.org/pipermail/squeak-dev/2007-November/122434…
On the other hand, the endOfStreamAction of Squeak_Xtream is pleasant
at first, but hard to handle across wrappers. I don't yet have an
answer whether it scales on a more complete xtream library or not
(thinking of blocking streams...).
> Anyway, I'm now subscribed to the pharo list so I'm reachable both there and on vwnc.
>
> Martin
>
> "Nicolas Cellier"<nicolas.cellier.aka.nice(a)gmail.com> wrote:
>> Yes that's a correct description of the past and present.
>>
>> The futur is opened, and the main options for Squeak Xtream are:
>> 1) change goals to get closer to VW - with a compatible API and lot of
>> mud underneath to glue the implementation on squeak
>> 2) stay at a proof of concept experimental level
>> 3) continue developping independantly as a replacement for Stream
>>
>> There is a lot of buzz recently, and a renewed interest in VW Xtream.
>> So there is a chance to gather enough force to attempt a squeak port,
>> whether based on Squeak Xtream experiments or not.
>> But it's not to me alone to answer this challenge.
>>
>> Nicolas
>>
>> > Sven
>> >
>> >
>> > _______________________________________________
>> > Pharo-project mailing list
>> > Pharo-project(a)lists.gforge.inria.fr
>> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>> >
>>
>> _______________________________________________
>> Pharo-project mailing list
>> Pharo-project(a)lists.gforge.inria.fr
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>
Oct. 8, 2010