Better management of encoding of environment variables
Hi all, following the meeting we had here @Inria headquarters, I'll be backporting some of the improvements we did in the launcher this last month regarding the encoding of environment variables. I've opened for this issue https://pharo.fogbugz.com/f/cases/22658/ We have already studied possible alternatives with Pablo and Christophe and we have some conclusions and we propose some changes: API Proposal for OSEnvironment ========================= - *at: aVariableName * Gets the String value of an environment variable called `aVariableName` It is the system reponsibility to manage the encoding. Rationale: A common denominator for all platforms providing an already decoded string, because windows does not (compared to *nix systems) provide a encoded byte representation of the value. Windows has instead its own wide string representation. - *[optionally] rawAt: anEncodedVariableName* Gets the Byte value of an environment variable called `anEncodedVariableName`. It is the user responsibility to encode and decode argument and return values in the encoding of this preference. Rationale: Some systems may want to have the liberty to use different encodings, or even to put binary data in the variables. - *[optionally] at: aVariableName encoding: anEncoding* Gets the value of an environment variable called `aVariableName` using `anEncoding` to encode/decode arguments and return values. Rationale: *xes could potentially use different encodings for their environment variables or even use different encodings in different parts of their file system. Other Implementation details ========================= - VM primitives returning paths Strings should be carefuly managed to decode them, since they are actually C strings (so byte arrays) disguised as ByteStrings. - Windows requires calling the right *Wide version of the functions from C, plus the correct encoding routine. This could be implemented as an FFI call or by modifying the VM to do it properly instead of calling the Ascii version
On Mon, 12 Nov 2018 at 18:02, Guillermo Polito <guillermopolito@gmail.com> wrote:
Hi all,
following the meeting we had here @Inria headquarters, I'll be backporting some of the improvements we did in the launcher this last month regarding the encoding of environment variables.
I've opened for this issue https://pharo.fogbugz.com/f/cases/22658/
We have already studied possible alternatives with Pablo and Christophe and we have some conclusions and we propose some changes:
API Proposal for OSEnvironment =========================
- *at: aVariableName *
Gets the String value of an environment variable called `aVariableName` It is the system reponsibility to manage the encoding. Rationale: A common denominator for all platforms providing an already decoded string, because windows does not (compared to *nix systems) provide a encoded byte representation of the value. Windows has instead its own wide string representation.
- *[optionally] rawAt: anEncodedVariableName*
Gets the Byte value of an environment variable called `anEncodedVariableName`. It is the user responsibility to encode and decode argument and return values in the encoding of this preference. Rationale: Some systems may want to have the liberty to use different encodings, or even to put binary data in the variables.
- *[optionally] at: aVariableName encoding: anEncoding*
Gets the value of an environment variable called `aVariableName` using `anEncoding` to encode/decode arguments and return values. Rationale: *xes could potentially use different encodings for their environment variables or even use different encodings in different parts of their file system.
Other Implementation details =========================
- VM primitives returning paths Strings should be carefuly managed to decode them, since they are actually C strings (so byte arrays) disguised as ByteStrings. - Windows requires calling the right *Wide version of the functions from C, plus the correct encoding routine. This could be implemented as an FFI call or by modifying the VM to do it properly instead of calling the Ascii version
I haven't been using environment variables a lot so I don't have a strong technical opinion (although at a glance it makes reasonable sense). But I wanted to say I really like the way you've presented your offline discussion, conclusions and proposal. Thanks. cheers -ben
Hi all, Thanks Ben for reading. For those wanting a follow up, I've proposed this pull request: https://github.com/pharo-project/pharo/pull/1980. I'm still working on avoiding dependencies against UFFI, fixing one other test. This is however almost finished, and given that I had to adapt the original *abstract proposal* to fit the real system, here is an updated version: API Proposal for OSEnvironment and friends ========================= OSEnvironment is the common denominator for all platforms. They should implement at least the following messages with the following semantics: - *at: aVariableName [ifAbsent:/ifAbsentPut:/ifPresent:ifAbsent:]* Gets the String value of an environment variable called `aVariableName`. It is the system reponsibility to manage the encoding of *both arguments and return values*. - *at: aVariableName put: aValue* Sets the environment variable called `aVariableName` to value `aValue`. It is the system reponsibility to manage the encoding of *both arguments and return values*. - *removeKey: aVariableName* Removes the environment variable called `aVariableName`. It is the system reponsibility to manage the encoding of *both arguments and return values*. API Extensions for *Nix Systems (OSX & Linux) ========================= Since *Nixes environment variables are binary data that could be encoded in any encoding, the following methods provide more flexibility to access such data in the encoding of the choice of the user, or even in binary form. - *at: aVariableName encoding: anEncoding [ifAbsent:/ifAbsentPut:/ifPresent:ifAbsent:/put:] / removeKey:** aVariableName encoding: anEncoding* Variants of the common API from OSEnvironment. The encoding used as argument will be used to encode/decode *both arguments and return values*. - *rawAt: anEncodedVariableName encoding: anEncoding [ifAbsent:/ifAbsentPut:/ifPresent:ifAbsent:/put:] / removeRawKey:* *anEncodedVariableName* Variants of the common API from OSEnvironment. These methods assume arguments and return values are encoded/decoded by the user, so no marshalling or decoded is done by it. Rationale ========================= - Encoding/Decoding should be applied not only to values but to variables names too. In most cases Ascii overlaps with utf* and Latin* encodings, but this cannot be simply assumed. - Windows requires calling the right *Wide version of the functions from C, plus the correct encoding routine. This could be implemented as an FFI call or by modifying the VM to do it properly instead of calling the Ascii version. - Unix FileSystems and environment variables could mix strings in different encodings, thus the flexibility added by the low level *Nix extensions. Other Implementation Details ========================= - VM primitives returning paths Strings should be carefuly managed to decode them, since they are actually C strings (so byte arrays) disguised as ByteStrings. - Similar changes had to be applied to correctly obtain the current working directory in case it is a wide string. On Mon, Nov 12, 2018 at 1:31 PM Ben Coman <btc@openinworld.com> wrote:
On Mon, 12 Nov 2018 at 18:02, Guillermo Polito <guillermopolito@gmail.com> wrote:
Hi all,
following the meeting we had here @Inria headquarters, I'll be backporting some of the improvements we did in the launcher this last month regarding the encoding of environment variables.
I've opened for this issue https://pharo.fogbugz.com/f/cases/22658/
We have already studied possible alternatives with Pablo and Christophe and we have some conclusions and we propose some changes:
API Proposal for OSEnvironment =========================
- *at: aVariableName *
Gets the String value of an environment variable called `aVariableName` It is the system reponsibility to manage the encoding. Rationale: A common denominator for all platforms providing an already decoded string, because windows does not (compared to *nix systems) provide a encoded byte representation of the value. Windows has instead its own wide string representation.
- *[optionally] rawAt: anEncodedVariableName*
Gets the Byte value of an environment variable called `anEncodedVariableName`. It is the user responsibility to encode and decode argument and return values in the encoding of this preference. Rationale: Some systems may want to have the liberty to use different encodings, or even to put binary data in the variables.
- *[optionally] at: aVariableName encoding: anEncoding*
Gets the value of an environment variable called `aVariableName` using `anEncoding` to encode/decode arguments and return values. Rationale: *xes could potentially use different encodings for their environment variables or even use different encodings in different parts of their file system.
Other Implementation details =========================
- VM primitives returning paths Strings should be carefuly managed to decode them, since they are actually C strings (so byte arrays) disguised as ByteStrings. - Windows requires calling the right *Wide version of the functions from C, plus the correct encoding routine. This could be implemented as an FFI call or by modifying the VM to do it properly instead of calling the Ascii version
I haven't been using environment variables a lot so I don't have a strong technical opinion (although at a glance it makes reasonable sense). But I wanted to say I really like the way you've presented your offline discussion, conclusions and proposal. Thanks.
cheers -ben
-- 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
I have to add also
Other Implementation Details =========================
- VM primitives returning paths Strings should be carefuly managed to decode them, since they are actually C strings (so byte arrays) disguised as ByteStrings. - Similar changes had to be applied to correctly obtain the current working directory in case it is a wide string.
- The default encoding assumed so far in *nixes is utf8. A more robust implementation could obtain this from the locale, but this would be too much of a change as all the locale code should be revisited too.
Guillermo Polito <guillermopolito@gmail.com> wrote:
Hi all,
following the meeting we had here @Inria headquarters, I'll be backporting some of the improvements we did in the launcher this last month regarding the encoding of environment variables.
I've opened for this issue https://pharo.fogbugz.com/f/cases/22658/
We have already studied possible alternatives with Pablo and Christophe and we have some conclusions and we propose some changes:
API Proposal for OSEnvironment =========================
- *at: aVariableName *
Gets the String value of an environment variable called `aVariableName` It is the system reponsibility to manage the encoding. Rationale: A common denominator for all platforms providing an already decoded string, because windows does not (compared to *nix systems) provide a encoded byte representation of the value. Windows has instead its own wide string representation.
- *[optionally] rawAt: anEncodedVariableName*
Gets the Byte value of an environment variable called `anEncodedVariableName`. It is the user responsibility to encode and decode argument and return values in the encoding of this preference. Rationale: Some systems may want to have the liberty to use different encodings, or even to put binary data in the variables.
- *[optionally] at: aVariableName encoding: anEncoding*
Gets the value of an environment variable called `aVariableName` using `anEncoding` to encode/decode arguments and return values. Rationale: *xes could potentially use different encodings for their environment variables or even use different encodings in different parts of their file system.
Other Implementation details =========================
- VM primitives returning paths Strings should be carefuly managed to decode them, since they are actually C strings (so byte arrays) disguised as ByteStrings. - Windows requires calling the right *Wide version of the functions from C, plus the correct encoding routine. This could be implemented as an FFI call or by modifying the VM to do it properly instead of calling the Ascii version
What is the conclusion from this and issue 22658? See PR 2238. #getEnv: is public API Stephan
Hi Stephan, I'm sorry for the noise. At the time, both #at: and #getEnv: variants existed. The changes backported from the PharoLauncher were only using the getter versions of getEnv, but for Pharo I decided to implement also the setter versions. And after checking the code and its users in image, I've finally decided to go for an at:[[ifAbsent]put:] version. So I'd say that the leading **guideline** was at the end the one here in the mailing list, but also if you check the PR I've introduced a more complete and consistent API, following the one of dictionaries. https://github.com/pharo-project/pharo/pull/1980/files at: at:ifAbsent: at:ifPresent: at:ifPresent:ifAbsent: at:put: removeKey: Plus, in *nix, variants where an encoding can be specified. I'm sorry if I've introduced some confussion. On Wed, Jan 16, 2019 at 9:47 AM Stephan Eggermont <stephan@stack.nl> wrote:
Guillermo Polito <guillermopolito@gmail.com> wrote:
Hi all,
following the meeting we had here @Inria headquarters, I'll be
backporting
some of the improvements we did in the launcher this last month regarding the encoding of environment variables.
I've opened for this issue https://pharo.fogbugz.com/f/cases/22658/
We have already studied possible alternatives with Pablo and Christophe and we have some conclusions and we propose some changes:
API Proposal for OSEnvironment =========================
- *at: aVariableName *
Gets the String value of an environment variable called `aVariableName` It is the system reponsibility to manage the encoding. Rationale: A common denominator for all platforms providing an already decoded string, because windows does not (compared to *nix systems) provide a encoded byte representation of the value. Windows has instead its own wide string representation.
- *[optionally] rawAt: anEncodedVariableName*
Gets the Byte value of an environment variable called `anEncodedVariableName`. It is the user responsibility to encode and decode argument and return values in the encoding of this preference. Rationale: Some systems may want to have the liberty to use different encodings, or even to put binary data in the variables.
- *[optionally] at: aVariableName encoding: anEncoding*
Gets the value of an environment variable called `aVariableName` using `anEncoding` to encode/decode arguments and return values. Rationale: *xes could potentially use different encodings for their environment variables or even use different encodings in different parts of their file system.
Other Implementation details =========================
- VM primitives returning paths Strings should be carefuly managed to decode them, since they are actually C strings (so byte arrays) disguised as ByteStrings. - Windows requires calling the right *Wide version of the functions from C, plus the correct encoding routine. This could be implemented as an FFI call or by modifying the VM to do it properly instead of calling the Ascii version
What is the conclusion from this and issue 22658? See PR 2238. #getEnv: is public API
Stephan
-- 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 Web: http://guillep.github.io Phone: +33 06 52 70 66 13
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. If someone bypass the VM and use direct windows API thru FFI, then he takes the responsibility, but uniformity doesn't hurt. Le mer. 16 janv. 2019 à 10:14, Guillermo Polito <guillermopolito@gmail.com> a écrit :
Hi Stephan,
I'm sorry for the noise.
At the time, both #at: and #getEnv: variants existed. The changes backported from the PharoLauncher were only using the getter versions of getEnv, but for Pharo I decided to implement also the setter versions. And after checking the code and its users in image, I've finally decided to go for an at:[[ifAbsent]put:] version. So I'd say that the leading **guideline** was at the end the one here in the mailing list, but also if you check the PR I've introduced a more complete and consistent API, following the one of dictionaries.
https://github.com/pharo-project/pharo/pull/1980/files
at: at:ifAbsent: at:ifPresent: at:ifPresent:ifAbsent: at:put: removeKey:
Plus, in *nix, variants where an encoding can be specified.
I'm sorry if I've introduced some confussion.
On Wed, Jan 16, 2019 at 9:47 AM Stephan Eggermont <stephan@stack.nl> wrote:
Guillermo Polito <guillermopolito@gmail.com> wrote:
Hi all,
following the meeting we had here @Inria headquarters, I'll be
backporting
some of the improvements we did in the launcher this last month regarding the encoding of environment variables.
I've opened for this issue https://pharo.fogbugz.com/f/cases/22658/
We have already studied possible alternatives with Pablo and Christophe and we have some conclusions and we propose some changes:
API Proposal for OSEnvironment =========================
- *at: aVariableName *
Gets the String value of an environment variable called `aVariableName` It is the system reponsibility to manage the encoding. Rationale: A common denominator for all platforms providing an already decoded string, because windows does not (compared to *nix systems) provide a encoded byte representation of the value. Windows has instead its own wide string representation.
- *[optionally] rawAt: anEncodedVariableName*
Gets the Byte value of an environment variable called `anEncodedVariableName`. It is the user responsibility to encode and decode argument and return values in the encoding of this preference. Rationale: Some systems may want to have the liberty to use different encodings, or even to put binary data in the variables.
- *[optionally] at: aVariableName encoding: anEncoding*
Gets the value of an environment variable called `aVariableName` using `anEncoding` to encode/decode arguments and return values. Rationale: *xes could potentially use different encodings for their environment variables or even use different encodings in different parts of their file system.
Other Implementation details =========================
- VM primitives returning paths Strings should be carefuly managed to decode them, since they are actually C strings (so byte arrays) disguised as ByteStrings. - Windows requires calling the right *Wide version of the functions from C, plus the correct encoding routine. This could be implemented as an FFI call or by modifying the VM to do it properly instead of calling the Ascii version
What is the conclusion from this and issue 22658? See PR 2238. #getEnv: is public API
Stephan
--
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
Phone: +33 06 52 70 66 13
Nicolas Cellier <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. If someone bypass the VM and use direct windows API thru FFI, then he takes the responsibility, but uniformity doesn't hurt.
That sounds like a very good idea. Do you suggest to do that after the Pharo 7 release? Or is it simple enough that it can be done in time? On the unix side, do I need the explicit encoding or can I ask the OSEnvironment for the one I need? Before the Pharo 7 release we need at least a #getEnv: back and a class comment corresponding to what is expected. If we want to change to the new API it needs to be deprecated. Stephan
Hi Nicolas, On Wed, Jan 16, 2019 at 10:25 AM Nicolas Cellier < 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
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.
On 16 Jan 2019, at 10:59, Guillermo Polito <guillermopolito@gmail.com> wrote:
Hi Nicolas,
On Wed, Jan 16, 2019 at 10:25 AM Nicolas Cellier <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
Hi Sven, On Wed, Jan 16, 2019 at 2:37 AM Sven Van Caekenberghe <sven@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.
On 16 Jan 2019, at 10:59, Guillermo Polito <guillermopolito@gmail.com> wrote:
Hi Nicolas,
On Wed, Jan 16, 2019 at 10:25 AM Nicolas Cellier < 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
On 16 Jan 2019, at 23:23, Eliot Miranda <eliot.miranda@gmail.com> wrote:
Hi Sven,
On Wed, Jan 16, 2019 at 2:37 AM Sven Van Caekenberghe <sven@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.
OK, I can understand that ENV VAR access is more fundamental than FFI (although FFI is already essential for Pharo, also during startup).
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.
Right, bytes are always uninterpreted, else they would be something else. We got ByteArray>>#decodedWith: and ByteArray>>#utf8Decoded and our ByteArray inspector decodes automatically if it can.
On 16 Jan 2019, at 10:59, Guillermo Polito <guillermopolito@gmail.com> wrote:
Hi Nicolas,
On Wed, Jan 16, 2019 at 10:25 AM Nicolas Cellier <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
On Thu, Jan 17, 2019 at 04:57:18PM +0100, Sven Van Caekenberghe wrote:
On 16 Jan 2019, at 23:23, Eliot Miranda <eliot.miranda@gmail.com> wrote:
On Wed, Jan 16, 2019 at 2:37 AM Sven Van Caekenberghe <sven@stfx.eu> wrote:
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.
OK, I can understand that ENV VAR access is more fundamental than FFI (although FFI is already essential for Pharo, also during startup).
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.
Right, bytes are always uninterpreted, else they would be something else. We got ByteArray>>#decodedWith: and ByteArray>>#utf8Decoded and our ByteArray inspector decodes automatically if it can.
Hi Sven, I am the author of the getenv primitives, and I am also sadly uninformed about matters of character sets and strings in a multilingual environment. The primitives answer environment variable variable values as ByteString rather than ByteArray. This made sense to me at the time that I wrote it, because ByteString is easy to display in an inspector, and because it is easily converted to ByteArray. For an American English speaker this seems like a good choice, but I wonder now if it is a bad decision. After all, it is also trivially easy to convert a ByteArray to ByteString for display in the image. Would it be helpful to have getenv primitives that answer ByteArray instead, and to let all conversion (including in OSProcess) be done in the image? Thanks, Dave
Le mer. 16 janv. 2019 à 23:23, Eliot Miranda <eliot.miranda@gmail.com> a écrit :
Hi Sven,
On Wed, Jan 16, 2019 at 2:37 AM Sven Van Caekenberghe <sven@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@gmail.com> wrote:
Hi Nicolas,
On Wed, Jan 16, 2019 at 10:25 AM Nicolas Cellier < 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
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@gmail.com <mailto:guillermopolito@gmail.com>> wrote:
Hi Nicolas,
On Wed, Jan 16, 2019 at 10:25 AM Nicolas Cellier <nicolas.cellier.aka.nice@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
Le ven. 18 janv. 2019 à 14:35, ducasse <stepharo@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@gmail.com> wrote:
Hi Nicolas,
On Wed, Jan 16, 2019 at 10:25 AM Nicolas Cellier < 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
On Wed, 16 Jan 2019 at 18:37, Sven Van Caekenberghe <sven@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 ? 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). cheers -ben [4] https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-softwar...
On 16 Jan 2019, at 10:59, Guillermo Polito <guillermopolito@gmail.com> wrote:
Hi Nicolas,
On Wed, Jan 16, 2019 at 10:25 AM Nicolas Cellier < 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
On 1/16/19 1:24 AM, Nicolas Cellier 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 have not looked at this particular problem in detail, so I have no opinion on whether the VM is the right place for this particular functionality. However, I feel that in general trying to put everything that might be OS-specific into the VM is not the best design. To me, the purpose of a Smalltalk VM is to present an object-oriented abstraction of the underlying machine. Thinking that way leads me to believe that the following are examples of things that are good for a VM to do: * Memory is garbage-collected objects, not bytes. * Instructions are bytecodes, not underlying machine instructions. This works well to hide the differences between machine instruction sets, memory access, and other low-level things. However, no Smalltalk implementation that I know of has been able to use the VM to iron out all differences between different OSes. I do believe that it is a good idea to have cleanly-designed layers of the system, and that there should be an OS-independent layer and an OS-dependent layer with clean separation. But I think it might be better to put most of the OS-dependent layer in the image rather than in the VM. For one thing, the image is easier to change if there is a bug, or a lacking feature, or you're trying to support a new OS. And if it's in the image you get to do the programming in Smalltalk rather than C or Slang, which is more fun for most of us. And, let's face it, fun is an important metric in an open-source project -- things that are fun are much more likely to get done. Regards, -Martin
To be clear, I do not militate for putting everything in the VM. I prefer a lean VM. I'm cleaning what already exist in the VM. If something is in the VM, then it should behave as we expect from a VM: uniformely. A small fix in existing code base is more efficient than a full rewrite. But if a full rewrite is wanted for other reasons, no problem. Le jeu. 17 janv. 2019 à 02:00, Martin McClure <martin@hand2mouse.com> a écrit :
On 1/16/19 1:24 AM, Nicolas Cellier 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 have not looked at this particular problem in detail, so I have no opinion on whether the VM is the right place for this particular functionality.
It is not in the VM currently, only in OSProcessPlugin (and Windows variant). If some other plugins would depend on environment variables, then it might be interesting to provide this feature as a VM service. I don't know if it is the case. Also, some platform could have other strategies like querying the Registry in windows, a configuration file, etc... So we might provide a service for the basic or multi-level policy.
However, I feel that in general trying to put everything that might be
OS-specific into the VM is not the best design. To me, the purpose of a Smalltalk VM is to present an object-oriented abstraction of the underlying machine.
Thinking that way leads me to believe that the following are examples of
things that are good for a VM to do:
* Memory is garbage-collected objects, not bytes.
* Instructions are bytecodes, not underlying machine instructions.
This works well to hide the differences between machine instruction sets, memory access, and other low-level things. However, no Smalltalk implementation that I know of has been able to use the VM to iron out all differences between different OSes.
Files? Sockets? Until the threaded FFI is consolidated, there is a category of async algorithms that we cannot easily program at image side.
I do believe that it is a good idea to have cleanly-designed layers of
the system, and that there should be an OS-independent layer and an OS-dependent layer with clean separation. But I think it might be better to put most of the OS-dependent layer in the image rather than in the VM. For one thing, the image is easier to change if there is a bug, or a lacking feature, or you're trying to support a new OS.
For supporting a new OS, I'm not sure. Having an "edit on known platform-save-resume on new platform-crash" cycles is not a pleasure. Well for certain persons, the pleasure can be proportional to the hurdle height ;)
You must have the bare minimum services (GUI) running before pleasure comes back. A Smalltalk without an IDE is not superior to C with a good IDE. Trial and error is not superior to a good debugger. And if it's in the image you get to do the programming in Smalltalk
rather than C or Slang, which is more fun for most of us. And, let's face it, fun is an important metric in an open-source project -- things that are fun are much more likely to get done.
Regards,
-Martin
For example, the first time I wrote something like Smallapack, there was no choice: it was thru user defined primitives (st80 or Objectworks). So I had to write a wrapper in C code for each function exposed, with all the marshalling of arguments in C! When came DLLCC it became more fun.
But this does not apply to every library. If the library depends on tons of preprocessors definitions, macros, then we currently lack tools for performing an efficient job at image side. Some possible tools have been sketched in those mailing list, but so far, they are virtual.
On 17 Jan 2019, at 02:00, Martin McClure <martin@hand2mouse.com> wrote:
On 1/16/19 1:24 AM, Nicolas Cellier 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 have not looked at this particular problem in detail, so I have no opinion on whether the VM is the right place for this particular functionality.
However, I feel that in general trying to put everything that might be OS-specific into the VM is not the best design. To me, the purpose of a Smalltalk VM is to present an object-oriented abstraction of the underlying machine.
Thinking that way leads me to believe that the following are examples of things that are good for a VM to do:
* Memory is garbage-collected objects, not bytes.
* Instructions are bytecodes, not underlying machine instructions.
This works well to hide the differences between machine instruction sets, memory access, and other low-level things. However, no Smalltalk implementation that I know of has been able to use the VM to iron out all differences between different OSes.
I do believe that it is a good idea to have cleanly-designed layers of the system, and that there should be an OS-independent layer and an OS-dependent layer with clean separation. But I think it might be better to put most of the OS-dependent layer in the image rather than in the VM. For one thing, the image is easier to change if there is a bug, or a lacking feature, or you're trying to support a new OS.
And if it's in the image you get to do the programming in Smalltalk rather than C or Slang, which is more fun for most of us. And, let's face it, fun is an important metric in an open-source project -- things that are fun are much more likely to get done.
+100
Regards,
-Martin
On Thu, Jan 17, 2019 at 8:02 AM Sven Van Caekenberghe <sven@stfx.eu> wrote:
On 17 Jan 2019, at 02:00, Martin McClure <martin@hand2mouse.com> wrote:
On 1/16/19 1:24 AM, Nicolas Cellier 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 have not looked at this particular problem in detail, so I have no opinion on whether the VM is the right place for this particular functionality.
However, I feel that in general trying to put everything that might be OS-specific into the VM is not the best design. To me, the purpose of a Smalltalk VM is to present an object-oriented abstraction of the underlying machine.
Thinking that way leads me to believe that the following are examples of things that are good for a VM to do:
* Memory is garbage-collected objects, not bytes.
* Instructions are bytecodes, not underlying machine instructions.
This works well to hide the differences between machine instruction sets, memory access, and other low-level things. However, no Smalltalk implementation that I know of has been able to use the VM to iron out all differences between different OSes.
I do believe that it is a good idea to have cleanly-designed layers of the system, and that there should be an OS-independent layer and an OS-dependent layer with clean separation. But I think it might be better to put most of the OS-dependent layer in the image rather than in the VM. For one thing, the image is easier to change if there is a bug, or a lacking feature, or you're trying to support a new OS.
And if it's in the image you get to do the programming in Smalltalk rather than C or Slang, which is more fun for most of us. And, let's face it, fun is an important metric in an open-source project -- things that are fun are much more likely to get done.
+100
The VM *is* developed in Smalltalk https://www.researchgate.net/publication/328509577_Two_Decades_of_Smalltalk_...
Regards,
-Martin
-- _,,,^..^,,,_ best, Eliot
And if it's in the image you get to do the programming in Smalltalk rather than C or Slang, which is more fun for most of us. And, let's face it, fun is an important metric in an open-source project -- things that are fun are much more likely to get done.
+100
The VM *is* developed in Smalltalk https://www.researchgate.net/publication/328509577_Two_Decades_of_Smalltalk_... <https://www.researchgate.net/publication/328509577_Two_Decades_of_Smalltalk_...> It is not the point of the message of Martin. I imagine that Martin and Sven understand it perfectly that the VM is written in Slang and that there is a simulator. Still many of us agree with their analysis. The VM logic should be on execution and try to delegate to the image most of the rest.
Stef
Hi Nicolas, Motivated by the discussion on Pharo list, I added new primitives to OSProcessPlugin to answer environment variables and path information as raw ByteArray, such that those byte arrays can be converted in the image to strings with any encoding. I did the changes in "trunk" OSPP, and am now implementing them in the oscog branch. I have tested the Unix changes in both branches. Unfortunately I do not have a Windows development at the moment, so I need to ask for help. In Win32OSProcessPlugin, I am adding two primitives: #primitiveGetCurrentWorkingDirectoryAsBytes #primitiveGetEnvironmentStringsAsBytes These are based on the two string primitives, which remain available: #primitiveGetCurrentWorkingDirectory #primitiveGetEnvironmentStrings The string primitives include your recent changes for UTF8 encoding, and the "xxxAsBytes" variants are based on my earlier logic without the UTF8 support. This means that OSProcess on Windows will use your UTF8 string support, and the additional primitives (based on the old logic, and answering raw bytes) will be available for people who want to do the encoding work in the image. Does this sound like the right approach? Thanks, Dave I have a question concerning the Win32 changes. On Wed, Jan 16, 2019 at 10:24:51AM +0100, Nicolas Cellier 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. If someone bypass the VM and use direct windows API thru FFI, then he takes the responsibility, but uniformity doesn't hurt.
Le mer. 16 janv. 2019 ?? 10:14, Guillermo Polito <guillermopolito@gmail.com> a ??crit :
Hi Stephan,
I'm sorry for the noise.
At the time, both #at: and #getEnv: variants existed. The changes backported from the PharoLauncher were only using the getter versions of getEnv, but for Pharo I decided to implement also the setter versions. And after checking the code and its users in image, I've finally decided to go for an at:[[ifAbsent]put:] version. So I'd say that the leading **guideline** was at the end the one here in the mailing list, but also if you check the PR I've introduced a more complete and consistent API, following the one of dictionaries.
https://github.com/pharo-project/pharo/pull/1980/files
at: at:ifAbsent: at:ifPresent: at:ifPresent:ifAbsent: at:put: removeKey:
Plus, in *nix, variants where an encoding can be specified.
I'm sorry if I've introduced some confussion.
On Wed, Jan 16, 2019 at 9:47 AM Stephan Eggermont <stephan@stack.nl> wrote:
Guillermo Polito <guillermopolito@gmail.com> wrote:
Hi all,
following the meeting we had here @Inria headquarters, I'll be
backporting
some of the improvements we did in the launcher this last month regarding the encoding of environment variables.
I've opened for this issue https://pharo.fogbugz.com/f/cases/22658/
We have already studied possible alternatives with Pablo and Christophe and we have some conclusions and we propose some changes:
API Proposal for OSEnvironment =========================
- *at: aVariableName *
Gets the String value of an environment variable called `aVariableName` It is the system reponsibility to manage the encoding. Rationale: A common denominator for all platforms providing an already decoded string, because windows does not (compared to *nix systems) provide a encoded byte representation of the value. Windows has instead its own wide string representation.
- *[optionally] rawAt: anEncodedVariableName*
Gets the Byte value of an environment variable called `anEncodedVariableName`. It is the user responsibility to encode and decode argument and return values in the encoding of this preference. Rationale: Some systems may want to have the liberty to use different encodings, or even to put binary data in the variables.
- *[optionally] at: aVariableName encoding: anEncoding*
Gets the value of an environment variable called `aVariableName` using `anEncoding` to encode/decode arguments and return values. Rationale: *xes could potentially use different encodings for their environment variables or even use different encodings in different parts of their file system.
Other Implementation details =========================
- VM primitives returning paths Strings should be carefuly managed to decode them, since they are actually C strings (so byte arrays) disguised as ByteStrings. - Windows requires calling the right *Wide version of the functions from C, plus the correct encoding routine. This could be implemented as an FFI call or by modifying the VM to do it properly instead of calling the Ascii version
What is the conclusion from this and issue 22658? See PR 2238. #getEnv: is public API
Stephan
--
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
Phone: +33 06 52 70 66 13
participants (9)
-
Ben Coman -
David T. Lewis -
ducasse -
Eliot Miranda -
Guillermo Polito -
Martin McClure -
Nicolas Cellier -
Stephan Eggermont -
Sven Van Caekenberghe