Pharo-dev
By thread
pharo-dev@lists.pharo.org
By month
Messages by month
- ----- 2026 -----
- 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
January 2019
- 376 messages
[ANN] New stable VM version.
by Esteban Lorenzano
Hi,
Yes, I needed to promote a new stable version because last weekâs was having a bug (which is not fixed).
This one is based on the build:
201901172323-5a38b34
Enjoy (and please report problems)
Esteban
Jan. 18, 2019
Re: [Pharo-dev] Better management of encoding of environment variables
by Ben Coman
On Fri, 18 Jan 2019 at 21:39, Sven Van Caekenberghe <sven(a)stfx.eu> wrote:
>
>
> > On 18 Jan 2019, at 14:23, Guillermo Polito <guillermopolito(a)gmail.com>
> wrote:
> >
> >
> > I think that will just overcomplicate things. Right now, all Strings in
> Pharo are unicode strings.
Cool. I didn't realise that. But to be pedantic, which unicode encoding?
Should I presume from Sven's "UTF-8 encoding step" comment below
and the WideString class comment "This class represents the array of 32
bit wide characters"
that the WideString encoding is UTF-32? So should its comment be updated
to advise that?
cheers -ben
Characters are represented with their corresponding unicode codepoint.
> > If all characters in a string have codepoints < 256 then they are just
> stored in a bytestring. Otherwise they are WideStrings.
> >
> > I think assuming a single representation for strings, and then encode
> when interacting with external apps/APIs is MUCH simpler.
>
> Absolutely !
>
> (and yes I know that for outgoing FFI calls that might mean a UTF-8
> encoding step, so be it).
>
Jan. 18, 2019
Re: [Pharo-dev] DebugSession>>activePC:
by Marcus Denker
> On 18 Jan 2019, at 14:26, ducasse <stepharo(a)netcourrier.com> wrote:
>
> I simply love the dynamic rewriting this is just too cool. We should systematically use it.
> I will continue to use it in any deprecation.
>
On my TODO is to make it stand-alone and provide is as a âcompatibility transformâ, too.
So we can add it to methods that we want to keep for compatibility, but they will nevertheless transform the code automatically.
(this then might be disabled in production to not transform)
> Now I have a simple question (You can explain it to me over lunch one of these days).
>
> I do not get why RBAST would not be a good representation for the compiler?
> I would like to know what is the difference.
>
I think it is a good one. I have not yet seen a reason why not. But remember, Roel left Squeak because his visitor pattern for the compiler was rejected as a dumb idea⦠so there are definitely different views on core questions.
E.g. the RB AST is annotated and the whole things for sure uses a bit more memory than the compiler designed for a machine from 1978.
> You mean that before going from BC to AST was difficult?
You need to do the mapping somehow, the compiler needs to remember the BC offset in the code generation phase and the AST (somehow) needs to store that information (either in every node or some table).
> How opal performs it? It does not use the source of the method to recreate the AST but he can do it from the BC?
>
It uses the IR (which I still am not 100% sure about, it came from the old âClosureCompilerâ Design and it turned out to be quite useful, for example for the mapping: every IR node retains the offset of the BC it creates, then the IR Nodes
retain the AST node that created them.
-> so we just do a query: âIRMethod, give me the IRInstruction that created BC offset X. then âIR, which AST node did create you? then the AST Node: what is your highlight interval in the source?
The devil is in the detail as one IR can produce multiple byte code offsets (and byte codes) and one byte code might be created by two IR nodes, but it does seem to work with some tricks.
Which I want to remove by improving the mapping and even the IR more⦠there is even the question: do we need the IR? could we not do it simpler?
The IR was quite nice back when we tried to do things with byte code manipulation (Bytesurgeon), now it feels a bit of an overkill. But it simplifies e.g. the bc mapping.
Marcus
Jan. 18, 2019
Re: [Pharo-dev] Better management of encoding of environment variables
by Sven Van Caekenberghe
> On 18 Jan 2019, at 14:23, Guillermo Polito <guillermopolito(a)gmail.com> wrote:
>
>
> I think that will just overcomplicate things. Right now, all Strings in Pharo are unicode strings. Characters are represented with their corresponding unicode codepoint.
> If all characters in a string have codepoints < 256 then they are just stored in a bytestring. Otherwise they are WideStrings.
>
> I think assuming a single representation for strings, and then encode when interacting with external apps/APIs is MUCH simpler.
Absolutely !
(and yes I know that for outgoing FFI calls that might mean a UTF-8 encoding step, so be it).
Jan. 18, 2019
Re: [Pharo-dev] [Vm-dev] Better management of encoding of environment variables
by Nicolas Cellier
Le ven. 18 janv. 2019 à 14:35, ducasse <stepharo(a)netcourrier.com> a écrit :
>
> What's important is to create abstract layers that insulate the un-needed
> complexity in lowest layers possible.
> The VM excels at insulating of course.
> At image side we have to assume the responsibility of not leaking too much
> by ourself.
>
> As Eliot said, right now the VM (and FFI) just take sequences of
> uninterpreted bytes (ByteArray) and pass them to API.
> The conversion ByteString/WideString <-> specifically-encoded ByteArray is
> performed at image side.
>
> With FFI, we could eventually make this conversion platform specific
> instead of always UTF8.
> The purpose would be to reduce back and forth conversions in chained API
> calls for example.
> For sanity, then better follow those rules:
> - the image does not attempt direct interaction with these opaque data
> (other than thru OS API)
> - nor preserve them across snapshots.
> Beware, conversion is not platform specific, but can be library specific
> (some library on windows will take UTF8).
> So we may reify the library and always double dispatch to the library, or
> we create upper level abstract messages that may chain several low level OS
> API calls.
> We would thus let complexity creep one more level, but only if we have
> good reason to do so.
> We don't want to trade uniformity for small gains.
> BTW, note that the xxxW API is already a huge uniformisation progress
> compared to the code-page specific xxxA API!
>
>
> Hi nicolas
>
> Iâm reading and trying to understand. but the xxx lost me. :)
>
>
> Sorry, I was talking of the windows API variants, W for Wide characters, A
for ASCII (or rather current-code-page in effect)
>
>
> Another strategy is to create more complex abstractions (i.e.
> parameterized) that can deal with a zoo of different underlying conventions.
> For example, this would be the EncodedString of VW.
> This strategy could be tempting, because it enables dealing with lower
> level platform-specific-encoded objects and still interact with them in the
> image transparently.
> But I strongly advise to think twice (or more) before introducing such
> complexity:
> - it breaks former invariants (thus potentially lot of code)
> - complexity tends to spread in many places
> I don't recommend it.
>
> PS: oups, sorry for out of band message, I wanted to send, but it seems
> that I did not press the button properly...
>
>>
>>> > On 16 Jan 2019, at 10:59, Guillermo Polito <guillermopolito(a)gmail.com>
>>> wrote:
>>> >
>>> > Hi Nicolas,
>>> >
>>> > On Wed, Jan 16, 2019 at 10:25 AM Nicolas Cellier <
>>> nicolas.cellier.aka.nice(a)gmail.com> wrote:
>>> > IMO, windows VM (and plugins) should do the UCS2 -> UTF8 conversion
>>> because the purpose of a VM is to provide an OS independant façade.
>>> > I made progress recently in this area, but we should finish the
>>> job/test/consolidate.
>>> >
>>> > I'm following your changes for windows from the shadows and I think
>>> they are awesome :).
>>> >
>>> > If someone bypass the VM and use direct windows API thru FFI, then he
>>> takes the responsibility, but uniformity doesn't hurt.
>>> >
>>> > So far we are using FFI for this, as you say we create first
>>> Win32WideStrings from utf8 strings and then we use ffi calls to the *W
>>> functions.
>>> > I don't think we can make it for Pharo7.0.0. The cycle to build, do
>>> some acceptance tests, and then bless a new VM as stable is far too long
>>> for our inminent release :).
>>> >
>>> > But this could be for a 7.1.0, and if you like I can surely give a
>>> hand on this.
>>> >
>>> > Guille
>>>
>>>
>>>
>>
>> --
>> _,,,^..^,,,_
>> best, Eliot
>>
>
>
Jan. 18, 2019
Re: [Pharo-dev] [Vm-dev] Better management of encoding of environment variables
by ducasse
>
> What's important is to create abstract layers that insulate the un-needed complexity in lowest layers possible.
> The VM excels at insulating of course.
> At image side we have to assume the responsibility of not leaking too much by ourself.
>
> As Eliot said, right now the VM (and FFI) just take sequences of uninterpreted bytes (ByteArray) and pass them to API.
> The conversion ByteString/WideString <-> specifically-encoded ByteArray is performed at image side.
>
> With FFI, we could eventually make this conversion platform specific instead of always UTF8.
> The purpose would be to reduce back and forth conversions in chained API calls for example.
> For sanity, then better follow those rules:
> - the image does not attempt direct interaction with these opaque data (other than thru OS API)
> - nor preserve them across snapshots.
> Beware, conversion is not platform specific, but can be library specific (some library on windows will take UTF8).
> So we may reify the library and always double dispatch to the library, or we create upper level abstract messages that may chain several low level OS API calls.
> We would thus let complexity creep one more level, but only if we have good reason to do so.
> We don't want to trade uniformity for small gains.
> BTW, note that the xxxW API is already a huge uniformisation progress compared to the code-page specific xxxA API!
Hi nicolas
Iâm reading and trying to understand. but the xxx lost me. :)
>
> Another strategy is to create more complex abstractions (i.e. parameterized) that can deal with a zoo of different underlying conventions.
> For example, this would be the EncodedString of VW.
> This strategy could be tempting, because it enables dealing with lower level platform-specific-encoded objects and still interact with them in the image transparently.
> But I strongly advise to think twice (or more) before introducing such complexity:
> - it breaks former invariants (thus potentially lot of code)
> - complexity tends to spread in many places
> I don't recommend it.
>
> PS: oups, sorry for out of band message, I wanted to send, but it seems that I did not press the button properly...
>
> > On 16 Jan 2019, at 10:59, Guillermo Polito <guillermopolito(a)gmail.com <mailto:guillermopolito@gmail.com>> wrote:
> >
> > Hi Nicolas,
> >
> > On Wed, Jan 16, 2019 at 10:25 AM Nicolas Cellier <nicolas.cellier.aka.nice(a)gmail.com <mailto:nicolas.cellier.aka.nice@gmail.com>> wrote:
> > IMO, windows VM (and plugins) should do the UCS2 -> UTF8 conversion because the purpose of a VM is to provide an OS independant façade.
> > I made progress recently in this area, but we should finish the job/test/consolidate.
> >
> > I'm following your changes for windows from the shadows and I think they are awesome :).
> >
> > If someone bypass the VM and use direct windows API thru FFI, then he takes the responsibility, but uniformity doesn't hurt.
> >
> > So far we are using FFI for this, as you say we create first Win32WideStrings from utf8 strings and then we use ffi calls to the *W functions.
> > I don't think we can make it for Pharo7.0.0. The cycle to build, do some acceptance tests, and then bless a new VM as stable is far too long for our inminent release :).
> >
> > But this could be for a 7.1.0, and if you like I can surely give a hand on this.
> >
> > Guille
>
>
>
>
> --
> _,,,^..^,,,_
> best, Eliot
Jan. 18, 2019
Re: [Pharo-dev] DebugSession>>activePC:
by ducasse
I simply love the dynamic rewriting this is just too cool. We should systematically use it.
I will continue to use it in any deprecation.
Now I have a simple question (You can explain it to me over lunch one of these days).
I do not get why RBAST would not be a good representation for the compiler?
I would like to know what is the difference.
You mean that before going from BC to AST was difficult?
How opal performs it? It does not use the source of the method to recreate the AST but he can do it from the BC?
Stef
>>
>
> But I like the âhigh levelâ: using a shared AST between the compiler and the tools *and* having a mapping BC -> AST -> Text.
>
> Of course I understand that the choice to use the RB AST for the compiler is not a âtraditionalâ one.. but it turned out to work very well *and* it brings some amazing power, as we have now not only a mapping bc->text offset, but a mapping bc->AST, too. This e.g. (just a a simple example) makes the magic of the runtime transforming deprecations possible. See #transform on class Deprecation, the #sourceNodeExecuted:
>
> transform
> | node rewriteRule aMethod |
> self shouldTransform ifFalse: [ ^ self ].
> self rewriterClass ifNil:[ ^ self signal ].
> aMethod := self contextOfSender method.
> aMethod isDoIt ifTrue:[^ self]. "no need to transform doits"
> node := self contextOfSender sourceNodeExecuted.
> rewriteRule := self rewriterClass new
> replace: rule key with: rule value.
> (rewriteRule executeTree: node)
> ifFalse: [ ^ self ].
> node replaceWith: rewriteRule tree.
> Author
> useAuthor: 'AutoDeprecationRefactoring'
> during: [aMethod origin compile: aMethod ast formattedCode classified: aMethod protocol].
>
>
> Marcus
Jan. 18, 2019
Re: [Pharo-dev] Better management of encoding of environment variables
by Guillermo Polito
On Fri, Jan 18, 2019 at 1:48 PM Ben Coman via Pharo-dev <
pharo-dev(a)lists.pharo.org> wrote:
>
>
>
>
> On Wed, 16 Jan 2019 at 18:37, Sven Van Caekenberghe <sven(a)stfx.eu> wrote:
>
>> Still, one of the conclusions of previous discussions about the encoding
>> of environment variables was/is that there is no single correct solution.
>> OS's are not consistent in how the encoding is done in all (historical)
>> contexts (like sometimes,
>
>
>
>> 1 env var defines the encoding to use for others,
>
>
> ouch. That one point nearly made my retract my comment next paragraph,
> but is there much more complexity?
> or just a case of utf8<==>appSpecificEncoding rather than
> ascii<==>appSpecificEncoding ?
>
It's not muuuuch more complex. The problem is that usually the bugs that
arise from wrongly managing such conversions can be super obscure.
> Sorry if I'm rehashing past discussion (do you have a link?), but
> considering...
> * 92% of web pages are UTF8 encoded[1] such that pragmatically UTF8 *is*
> the standard for text
> * Strings so pervasive in a system
> ...would there be an overall benefit to adopt UTF8 as the encoding for
> Strings
> consistently provided across the cross-platform vm interface?
> (i.e. fixing platforms that don't comply to the standard due to their
> historical baggage)
>
> And I found it interesting Microsoft are making some moves towards UTF8
> [2]...
> "With insider build 17035 and the April 2018 update (nominal build 17134)
> for Windows 10, a "Beta: Use Unicode UTF-8 for worldwide language support"
> checkbox appeared for setting the locale code page to UTF-8.[a] This allows
> for calling "narrow" functions, including fopen and SetWindowTextA, with
> UTF-8 strings. "
>
> The approach vm-side could be similar to Section 10 How to do text on
> Windows [3]
> with the philosophy of "performing the [conversions] as close to API calls
> as possible,
> and never holding the [converted] data."
>
> [1]
> https://w3techs.com/technologies/history_overview/character_encoding/ms/y
> [2] https://en.wikipedia.org/wiki/Unicode_in_Microsoft_Windows
> [3] http://utf8everywhere.org/
>
>
> different applications do different things, and other such nice stuff),
>> and certainly not across platforms.
>>
>> So this is really complex.
>>
>> Do we want to hide this in some obscure VM C code that very few people
>> can see, read, let alone help with ?
>>
>> The image side is perfectly capable of dealing with platform differences
>> in a clean/clear way, and at least we can then use the full power of our
>> language and our tools.
>>
>
> Big question... Do we currently have primitives of the same name returning
> different encodings on different platforms? I presume that would be
> awkward.
> If the image is handle encoding differences, should separate primitives be
> used? e.g. utf8GetEnv & utf16getEnv
>
> Could I get some feedback on [4] saying... **The Single Most Important
> Fact About Encodings**
> If you completely forget everything I just explained, please remember one
> extremely important fact.
> It does not make sense to have a string without knowing what encoding it
> uses. "
>
> And so... does our String nowadays require an 'encoding' instance variable
> such that this is *always* associated?
> This might remove any need for separate utf8GetEnv & utf16getEnv (if that
> was even a reasonable idea).
>
I think that will just overcomplicate things. Right now, all Strings in
Pharo are unicode strings. Characters are represented with their
corresponding unicode codepoint.
If all characters in a string have codepoints < 256 then they are just
stored in a bytestring. Otherwise they are WideStrings.
I think assuming a single representation for strings, and then encode when
interacting with external apps/APIs is MUCH simpler.
> cheers -ben
>
> [4]
> https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-softwa…
>
>
>
>> > On 16 Jan 2019, at 10:59, Guillermo Polito <guillermopolito(a)gmail.com>
>> wrote:
>> >
>> > Hi Nicolas,
>> >
>> > On Wed, Jan 16, 2019 at 10:25 AM Nicolas Cellier <
>> nicolas.cellier.aka.nice(a)gmail.com> wrote:
>> > IMO, windows VM (and plugins) should do the UCS2 -> UTF8 conversion
>> because the purpose of a VM is to provide an OS independant façade.
>> > I made progress recently in this area, but we should finish the
>> job/test/consolidate.
>> >
>> > I'm following your changes for windows from the shadows and I think
>> they are awesome :).
>> >
>> > If someone bypass the VM and use direct windows API thru FFI, then he
>> takes the responsibility, but uniformity doesn't hurt.
>> >
>> > So far we are using FFI for this, as you say we create first
>> Win32WideStrings from utf8 strings and then we use ffi calls to the *W
>> functions.
>> > I don't think we can make it for Pharo7.0.0. The cycle to build, do
>> some acceptance tests, and then bless a new VM as stable is far too long
>> for our inminent release :).
>> >
>> > But this could be for a 7.1.0, and if you like I can surely give a hand
>> on this.
>> >
>> > Guille
>>
>>
>>
--
Guille Polito
Research Engineer
Centre de Recherche en Informatique, Signal et Automatique de Lille
CRIStAL - UMR 9189
French National Center for Scientific Research - *http://www.cnrs.fr
<http://www.cnrs.fr>*
*Web:* *http://guillep.github.io* <http://guillep.github.io>
*Phone: *+33 06 52 70 66 13
Jan. 18, 2019
Re: [Pharo-dev] DebugSession>>activePC:
by Marcus Denker
> On 11 Jan 2019, at 20:28, Eliot Miranda <eliot.miranda(a)gmail.com> wrote:
>
> Hi Thomas,
>
> forgive me, my first response was too terse. Having thought about it in the shower it becomes clear :-)
>
>> On Jan 11, 2019, at 6:49 AM, Thomas Dupriez <tdupriez(a)ens-paris-saclay.fr> wrote:
>>
>> Hi,
>>
>> Yes, my question was just of the form: "Hey there's this method in DebugSession. What is it doing? What's the intention behind it? Does someone know?". There was no hidden agenda behind it.
>>
>> @Eliot
>>
>> After taking another look at this method, there's something I don't understand:
>>
>> activePC: aContext
>> ^ (self isLatestContext: aContext)
>> ifTrue: [ interruptedContext pc ]
>> ifFalse: [ self previousPC: aContext ]
>>
>> isLatestContext: checks whether its argument is the suspended context (the context at the top of the stack of the interrupted process). And if that's true, activePC: returns the pc of **interruptedContext**, not of the suspended context. These two contexts are different when the debugger opens on an exception, so this method is potentially returning a pc for another context than its argument...
>>
>> Another question I have to improve the comment for this method is: what's the high-level meaning of this concept of "activePC". You gave the formal definition, but what's the point of defining this so to speak? What makes this concept interesting enough to warrant defining it and giving it a name?
>
> There are two âmodesâ where a pc us mapped to a source range. One is when stepping a context in the debugger (the context is on top and is actively executing bytecodes). Here the debugger stops immediately before a send or assignment or return, so that for sends we can do into or over, or for assignments or returns check stack top to see what will be assigned or returned. In this mode we want the pc of the send, assign or return to map to the source range for the send, or the expression being assigned or returned. Since this is the âcommon caseâ, and since this is the only choice that makes sense for assignments ta and returns, the bytecode compiler constructs itâs pc to source range map in terms of the pc of the first byte if the send, assign or return bytecode.
>
> The second âmodeâ is when selecting a context below the top context. The pc for any context below the top context will be the return pc for a send, because the send has already happened. The compiler could choose to map this pc to the send, but it would not match what works for the common case. Another choice would appear be to have two map entries, one for the send and one for the return pc, both mapping to the source range. But this wouldnât work because the result of a send might be assigned or returned and so there is a potential conflict. I stead the reasonable solution is to select the previous pc for contexts below the top of context, which will be the pc for the start of the send bytecode.
>
I checked with Thomas
-> for source mapping, we use the API of the method map. The map does the âget the mapping for the instruction beforeâ, it just needs to be told that we ask the range for an active context:
#rangeForPC:contextIsActiveContext:
it is called
^aContext debuggerMap
rangeForPC: aContext pc
contextIsActiveContext: (self isLatestContext: aContext) ]
So the logic was move from the debugger to the Map. (I think this is even your design?), and thus the logic inside the debugger is not needed anymore.
-> For the question why the AST node of the Block has no simple method to check if it is an âisOptimizedâ block (e.g. in an ifTrue:): Yes, that might be nice. The reason why is is not there is that the compiler internally using OCOptimizedBlockScope and a check on the AST level was never needed. I would have added it as soon as it would be needed (quite easy to do).
On the AST level there is already a check, though, if a *send* is optimized, which is used for code generation (#isInlined).
The question why we did not add more compatibility layers to the old AST is that is is quite different.. so even with some methods here and there 99% of clients need changes, so I did not even investigate it too much. With the idea that if we end up in a situation where we need just a method, we can just add it as needed.
In general, I have no srtong feelings about the details of the implementation of Opal. Itâs just what was possible, with the resources and the understanding that I had at the point it was done. There are for sure even mistakes. I always make mistakes.
In addition, it is based on a prior compiler which was done for a different closure model whose Design-choices influenced it too much I think, sometimes good, sometimes not.
But I like the âhigh levelâ: using a shared AST between the compiler and the tools *and* having a mapping BC -> AST -> Text.
Of course I understand that the choice to use the RB AST for the compiler is not a âtraditionalâ one.. but it turned out to work very well *and* it brings some amazing power, as we have now not only a mapping bc->text offset, but a mapping bc->AST, too. This e.g. (just a a simple example) makes the magic of the runtime transforming deprecations possible. See #transform on class Deprecation, the #sourceNodeExecuted:
transform
| node rewriteRule aMethod |
self shouldTransform ifFalse: [ ^ self ].
self rewriterClass ifNil:[ ^ self signal ].
aMethod := self contextOfSender method.
aMethod isDoIt ifTrue:[^ self]. "no need to transform doits"
node := self contextOfSender sourceNodeExecuted.
rewriteRule := self rewriterClass new
replace: rule key with: rule value.
(rewriteRule executeTree: node)
ifFalse: [ ^ self ].
node replaceWith: rewriteRule tree.
Author
useAuthor: 'AutoDeprecationRefactoring'
during: [aMethod origin compile: aMethod ast formattedCode classified: aMethod protocol].
Marcus
Jan. 18, 2019
Re: [Pharo-dev] [Vm-dev] Better management of encoding of environment variables
by Nicolas Cellier
Le mer. 16 janv. 2019 Ã 23:23, Eliot Miranda <eliot.miranda(a)gmail.com> a
écrit :
>
> Hi Sven,
>
> On Wed, Jan 16, 2019 at 2:37 AM Sven Van Caekenberghe <sven(a)stfx.eu>
> wrote:
>
>> Still, one of the conclusions of previous discussions about the encoding
>> of environment variables was/is that there is no single correct solution.
>> OS's are not consistent in how the encoding is done in all (historical)
>> contexts (like sometimes, 1 env var defines the encoding to use for others,
>> different applications do different things, and other such nice stuff), and
>> certainly not across platforms.
>>
>> So this is really complex.
>>
>> Do we want to hide this in some obscure VM C code that very few people
>> can see, read, let alone help with ?
>>
>> The image side is perfectly capable of dealing with platform differences
>> in a clean/clear way, and at least we can then use the full power of our
>> language and our tools.
>>
>
> Agreed. At the same time I think it is very important that we don't reply
> on the FFI for environment variable access. This is a basic cross-platform
> facility. So I would like to see the environment accessed through
> primitives, but have the image place interpretation on the result of the
> primitive(s), and have the primitive(s) answer a raw result, just a
> sequence of uninterpreted bytes.
>
> VisualWorks takes this approach and provides a class UninterpretedBytes
> that the VM is aware of. That's always seemed like an ugly name and
> overkill to me. I would just use ByteArray and provide image level
> conversion from ByteArray to String, which is what I believe we have anyway.
>
>
What's important is to create abstract layers that insulate the un-needed
complexity in lowest layers possible.
The VM excels at insulating of course.
At image side we have to assume the responsibility of not leaking too much
by ourself.
As Eliot said, right now the VM (and FFI) just take sequences of
uninterpreted bytes (ByteArray) and pass them to API.
The conversion ByteString/WideString <-> specifically-encoded ByteArray is
performed at image side.
With FFI, we could eventually make this conversion platform specific
instead of always UTF8.
The purpose would be to reduce back and forth conversions in chained API
calls for example.
For sanity, then better follow those rules:
- the image does not attempt direct interaction with these opaque data
(other than thru OS API)
- nor preserve them across snapshots.
Beware, conversion is not platform specific, but can be library specific
(some library on windows will take UTF8).
So we may reify the library and always double dispatch to the library, or
we create upper level abstract messages that may chain several low level OS
API calls.
We would thus let complexity creep one more level, but only if we have good
reason to do so.
We don't want to trade uniformity for small gains.
BTW, note that the xxxW API is already a huge uniformisation progress
compared to the code-page specific xxxA API!
Another strategy is to create more complex abstractions (i.e.
parameterized) that can deal with a zoo of different underlying conventions.
For example, this would be the EncodedString of VW.
This strategy could be tempting, because it enables dealing with lower
level platform-specific-encoded objects and still interact with them in the
image transparently.
But I strongly advise to think twice (or more) before introducing such
complexity:
- it breaks former invariants (thus potentially lot of code)
- complexity tends to spread in many places
I don't recommend it.
PS: oups, sorry for out of band message, I wanted to send, but it seems
that I did not press the button properly...
>
>> > On 16 Jan 2019, at 10:59, Guillermo Polito <guillermopolito(a)gmail.com>
>> wrote:
>> >
>> > Hi Nicolas,
>> >
>> > On Wed, Jan 16, 2019 at 10:25 AM Nicolas Cellier <
>> nicolas.cellier.aka.nice(a)gmail.com> wrote:
>> > IMO, windows VM (and plugins) should do the UCS2 -> UTF8 conversion
>> because the purpose of a VM is to provide an OS independant façade.
>> > I made progress recently in this area, but we should finish the
>> job/test/consolidate.
>> >
>> > I'm following your changes for windows from the shadows and I think
>> they are awesome :).
>> >
>> > If someone bypass the VM and use direct windows API thru FFI, then he
>> takes the responsibility, but uniformity doesn't hurt.
>> >
>> > So far we are using FFI for this, as you say we create first
>> Win32WideStrings from utf8 strings and then we use ffi calls to the *W
>> functions.
>> > I don't think we can make it for Pharo7.0.0. The cycle to build, do
>> some acceptance tests, and then bless a new VM as stable is far too long
>> for our inminent release :).
>> >
>> > But this could be for a 7.1.0, and if you like I can surely give a hand
>> on this.
>> >
>> > Guille
>>
>>
>>
>
> --
> _,,,^..^,,,_
> best, Eliot
>
Jan. 18, 2019