Thread overview | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
October 25, 2010 [phobos] review for environment | ||||
---|---|---|---|---|
| ||||
Here are a few thoughts about http://www.dsource.org/projects/phobos/changeset/1867. On many machines the environment might be considerably large, and copying it doesn't sound like the most effective solution. Would it be possible to define a simple (input or forward) range for Environment? Andrei |
October 25, 2010 [phobos] review for environment | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | The only place where I see the environment is copied is toAA, which is not necessary to be able to use the environment. You can use opIndex directly.
Am I missing something? Are you missing something?
-Steve
----- Original Message ----
> From: Andrei Alexandrescu <andrei at erdani.com>
> To: Discuss the phobos library for D <phobos at puremagic.com>
> Sent: Mon, October 25, 2010 5:27:12 PM
> Subject: [phobos] review for environment
>
> Here are a few thoughts about
>http://www.dsource.org/projects/phobos/changeset/1867.
>
> On many machines the environment might be considerably large, and copying it
>doesn't sound like the most effective solution.
>
> Would it be possible to define a simple (input or forward) range for
>Environment?
>
>
> Andrei
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
>
|
October 25, 2010 [phobos] review for environment | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steve Schveighoffer | Yah, I was referring to opAA.
Andrei
On 10/25/10 16:39 CDT, Steve Schveighoffer wrote:
> The only place where I see the environment is copied is toAA, which is not necessary to be able to use the environment. You can use opIndex directly.
>
> Am I missing something? Are you missing something?
>
> -Steve
>
>
>
> ----- Original Message ----
>> From: Andrei Alexandrescu<andrei at erdani.com>
>> To: Discuss the phobos library for D<phobos at puremagic.com>
>> Sent: Mon, October 25, 2010 5:27:12 PM
>> Subject: [phobos] review for environment
>>
>> Here are a few thoughts about http://www.dsource.org/projects/phobos/changeset/1867.
>>
>> On many machines the environment might be considerably large, and copying it doesn't sound like the most effective solution.
>>
>> Would it be possible to define a simple (input or forward) range for
>> Environment?
>>
>>
>> Andrei
>> _______________________________________________
>> phobos mailing list
>> phobos at puremagic.com
>> http://lists.puremagic.com/mailman/listinfo/phobos
>>
>
>
>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
|
October 25, 2010 [phobos] review for environment | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | http://dsource.org/projects/phobos/changeset/1989 That was at least most of it. Not sure if I missed anything. On 10/25/2010 5:46 PM, Andrei Alexandrescu wrote: > Yah, I was referring to opAA. > > Andrei > > On 10/25/10 16:39 CDT, Steve Schveighoffer wrote: >> The only place where I see the environment is copied is toAA, which >> is not >> necessary to be able to use the environment. You can use opIndex >> directly. >> >> Am I missing something? Are you missing something? >> >> -Steve >> >> >> >> ----- Original Message ---- >>> From: Andrei Alexandrescu<andrei at erdani.com> >>> To: Discuss the phobos library for D<phobos at puremagic.com> >>> Sent: Mon, October 25, 2010 5:27:12 PM >>> Subject: [phobos] review for environment >>> >>> Here are a few thoughts about http://www.dsource.org/projects/phobos/changeset/1867. >>> >>> On many machines the environment might be considerably large, and >>> copying it >>> doesn't sound like the most effective solution. >>> >>> Would it be possible to define a simple (input or forward) range for >>> Environment? >>> >>> >>> Andrei >>> _______________________________________________ >>> phobos mailing list >>> phobos at puremagic.com >>> http://lists.puremagic.com/mailman/listinfo/phobos >>> >> >> >> >> _______________________________________________ >> phobos mailing list >> phobos at puremagic.com >> http://lists.puremagic.com/mailman/listinfo/phobos > _______________________________________________ > phobos mailing list > phobos at puremagic.com > http://lists.puremagic.com/mailman/listinfo/phobos > |
October 25, 2010 [phobos] review for environment | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Simcha | I'm confused. That diff seems to be unrelated.
Andrei
On 10/25/10 17:55 CDT, David Simcha wrote:
> http://dsource.org/projects/phobos/changeset/1989
>
> That was at least most of it. Not sure if I missed anything.
>
> On 10/25/2010 5:46 PM, Andrei Alexandrescu wrote:
>> Yah, I was referring to opAA.
>>
>> Andrei
>>
>> On 10/25/10 16:39 CDT, Steve Schveighoffer wrote:
>>> The only place where I see the environment is copied is toAA, which
>>> is not
>>> necessary to be able to use the environment. You can use opIndex
>>> directly.
>>>
>>> Am I missing something? Are you missing something?
>>>
>>> -Steve
>>>
>>>
>>>
>>> ----- Original Message ----
>>>> From: Andrei Alexandrescu<andrei at erdani.com>
>>>> To: Discuss the phobos library for D<phobos at puremagic.com>
>>>> Sent: Mon, October 25, 2010 5:27:12 PM
>>>> Subject: [phobos] review for environment
>>>>
>>>> Here are a few thoughts about http://www.dsource.org/projects/phobos/changeset/1867.
>>>>
>>>> On many machines the environment might be considerably large, and
>>>> copying it
>>>> doesn't sound like the most effective solution.
>>>>
>>>> Would it be possible to define a simple (input or forward) range for
>>>> Environment?
>>>>
>>>>
>>>> Andrei
>>>> _______________________________________________
>>>> phobos mailing list
>>>> phobos at puremagic.com
>>>> http://lists.puremagic.com/mailman/listinfo/phobos
>>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> phobos mailing list
>>> phobos at puremagic.com
>>> http://lists.puremagic.com/mailman/listinfo/phobos
>> _______________________________________________
>> phobos mailing list
>> phobos at puremagic.com
>> http://lists.puremagic.com/mailman/listinfo/phobos
>>
>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
|
October 27, 2010 [phobos] review for environment | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu |
----- Original Message ----
> From: Andrei Alexandrescu <andrei at erdani.com>
>
> Yah, I was referring to opAA.
With Posix, you have environment variables stored in a __gshared global. Providing a local range on that data isn't a good idea. Windows provides the function GetEnvironmentStrings, which returns a memory block allocated to hold all the environment variables. You must call FreeEnvironmentStrings to free the memory.
These are the only ways to iterate variables. If you want individual variables for which you already know the names, there are functions for that, but Lars' code implements those through individual functions, not toAA.
The only way I could see it done better is to have a type that allows setting of the variables when you assign to the AA. But you still need to copy the data.
-Steve
|
October 28, 2010 [phobos] review for environment | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steve Schveighoffer | Thanks for the response.
Andrei
On 10/27/10 22:05 CDT, Steve Schveighoffer wrote:
>
>
>
>
> ----- Original Message ----
>> From: Andrei Alexandrescu<andrei at erdani.com>
>>
>> Yah, I was referring to opAA.
>
> With Posix, you have environment variables stored in a __gshared global. Providing a local range on that data isn't a good idea. Windows provides the function GetEnvironmentStrings, which returns a memory block allocated to hold all the environment variables. You must call FreeEnvironmentStrings to free the memory.
>
> These are the only ways to iterate variables. If you want individual variables for which you already know the names, there are functions for that, but Lars' code implements those through individual functions, not toAA.
>
> The only way I could see it done better is to have a type that allows setting of the variables when you assign to the AA. But you still need to copy the data.
>
> -Steve
>
>
>
>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
|
November 03, 2010 [phobos] review for environment | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | Sorry for not responding to this myself earlier, but I was on vacation with limited internet access.
I did try adding ranges, but quickly saw the issues Steve mentions. There are probably ways of working around them, but it won't improve performance, and I feel it's complete overkill for such a simple thing.
What I would like to get some feedback on is the way I've simulated a singleton object by using an abstract final class as a namespace for the various functions. To my knowledge, this has no precedent in Phobos. It does feel a bit weird, but it seemed like the simplest solution.
Also, would it be OK to mark getenv(), setenv(), and unsetenv() as
deprecated, now that environment has been present in two releases?
(Note that setenv() and unsetenv() are POSIX-only.)
-Lars
On Thu, 2010-10-28 at 13:28 -0500, Andrei Alexandrescu wrote:
> Thanks for the response.
>
> Andrei
>
> On 10/27/10 22:05 CDT, Steve Schveighoffer wrote:
> >
> >
> >
> >
> > ----- Original Message ----
> >> From: Andrei Alexandrescu<andrei at erdani.com>
> >>
> >> Yah, I was referring to opAA.
> >
> > With Posix, you have environment variables stored in a __gshared global. Providing a local range on that data isn't a good idea. Windows provides the function GetEnvironmentStrings, which returns a memory block allocated to hold all the environment variables. You must call FreeEnvironmentStrings to free the memory.
> >
> > These are the only ways to iterate variables. If you want individual variables for which you already know the names, there are functions for that, but Lars' code implements those through individual functions, not toAA.
> >
> > The only way I could see it done better is to have a type that allows setting of the variables when you assign to the AA. But you still need to copy the data.
> >
> > -Steve
> >
> >
> >
> >
> > _______________________________________________
> > phobos mailing list
> > phobos at puremagic.com
> > http://lists.puremagic.com/mailman/listinfo/phobos
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
|
November 04, 2010 [phobos] review for environment | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lars Tandle Kyllingstad | On Wednesday 03 November 2010 05:02:33 Lars Tandle Kyllingstad wrote: > Sorry for not responding to this myself earlier, but I was on vacation with limited internet access. > > I did try adding ranges, but quickly saw the issues Steve mentions. There are probably ways of working around them, but it won't improve performance, and I feel it's complete overkill for such a simple thing. > > What I would like to get some feedback on is the way I've simulated a singleton object by using an abstract final class as a namespace for the various functions. To my knowledge, this has no precedent in Phobos. It does feel a bit weird, but it seemed like the simplest solution. I did that in a couple of places in datetime, except that I didn't make the class abstract. Rather, I made this() private and marked it with @disable. I quite like the idiom for certain circumstances (for instance, I used it for the clock in datetime), but Andrei doesn't seem to like it much. However, I think that the main reason that nothing like that has been done in Phobos thus far is because modules are generally either a bunch of completely related functions (so the module works perfectly as a namespace for them), or they're a bunch of completely unrelated functions (so there's no need to group them into further namespaces). As module become more heterogenious - particularly once we have more that have actual types in them mixed in with free functions and aren't just a bunch of free functions - I expect that it will become more desirable to have explicit namespaces in some cases (though it could still be a fairly rare need). We'll have to see how that goes though. Regardless, I think that using a final, uninstantiatable class is the best way to create a namespace within a module in D at the moment. > Also, would it be OK to mark getenv(), setenv(), and unsetenv() as > deprecated, now that environment has been present in two releases? > (Note that setenv() and unsetenv() are POSIX-only.) I actually used those in a couple places in datetime. I'll have to switch them over to using environment (though they're only applicable to datetime on Posix systems). - Jonathan M Davis |
November 04, 2010 [phobos] review for environment | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | Le 2010-11-04 ? 6:34, Jonathan M Davis a ?crit : > Regardless, I think that using a final, uninstantiatable class is the best way to create a namespace within a module in D at the moment. It does pollute the object code with a useless vtable and ClassInfo object though. As long as there aren't too many of them it's probably fine. Another way to achieve what you want would be: template X() { void func(); } mixin X x; // now you can do x.func(); -- Michel Fortin michel.fortin at michelf.com http://michelf.com/ |
Copyright © 1999-2021 by the D Language Foundation