On 2013-07-15 00:06, Leandro Motta Barros wrote:
The documentation of GC.addRoot() (mentioned by Simen), contains this
interesting piece of example code:
// Also ensure that a moving collector does not relocate
// the object.
GC.setAttr(cast(void*)context, GC.BlkAttr.NO_MOVE);
Thanks.
Now I realise that D is much less intuitive than C++.
On Monday, 15 July 2013 at 03:49:10 UTC, Timothee Cour wrote:
I'm trying to interact with a process using std.process and
redirected stdin/stdout/stderr.
What would be the recommended way?
For example:
auto pipes=pipeShell(myprocess,Redirect.all);
while(true){
On Monday, 15 July 2013 at 04:27:42 UTC, JS wrote:
BTW, the usefulness is to group sub-enums into the same range.
This would make it easy/efficient to branch over a range in the
enum:
if (v in colors.Red) { v is a color in red }
instead of
if (v is color.Red || v is color.RedOrange || ...)
On Monday, 15 July 2013 at 07:37:36 UTC, Mike Parker wrote:
On Monday, 15 July 2013 at 04:27:42 UTC, JS wrote:
BTW, the usefulness is to group sub-enums into the same range.
This would make it easy/efficient to branch over a range in
the enum:
if (v in colors.Red) { v is a color in red }
Maybe this way?
final abstract class Colors
{
enum Red { RedOrange }
enum Green { GreenBlue}
enum Blue { BlueYellow }
}
void main() {
Colors.Red foo = Colors.Red.RedOrange;
assert(foo = Colors.Red.min foo = Colors.Red.max);
}
Hello,
I read the library reference for regex.
I really miss python's equivalent of finditer.
Sometimes matching is not on purpose and one will want to match
all the occurences to iterate over it since it is much more
regarding concerning the orders and repetitions.
my code :
On 2013-07-15, 11:32, Larry wrote:
Hello,
I read the library reference for regex.
I really miss python's equivalent of finditer.
Sometimes matching is not on purpose and one will want to match all the
occurences to iterate over it since it is much more regarding concerning
the orders and
On Monday, 15 July 2013 at 08:20:20 UTC, Namespace wrote:
Maybe this way?
final abstract class Colors
{
enum Red { RedOrange }
enum Green { GreenBlue}
enum Blue { BlueYellow }
}
void main() {
Colors.Red foo = Colors.Red.RedOrange;
assert(foo =
Humm,
A copy-paste of your code lead to :
[[segmentation
fault
So it doesn't work for me.
I use gdc if it might help !
On Monday, July 15, 2013 12:20:57 Manfred Nowak wrote:
From the docs:
If there are multiple ScopeGuardStatements in a scope, they are
executed in the reverse lexical order in which they appear.
Is lexical or executional order meant?
Under what circumstances would they not be the same
Jonathan M Davis wrote:
Under what circumstances would they not be the same thing?
http://dlang.org/statement.html#GotoStatement
At least the famous gots can make lexical ordering different to
executional ordering.
-manfred
On Monday, 15 July 2013 at 10:23:22 UTC, JS wrote:
On Monday, 15 July 2013 at 10:17:08 UTC, JS wrote:
On Monday, 15 July 2013 at 08:20:20 UTC, Namespace wrote:
Maybe this way?
final abstract class Colors
{
enum Red { RedOrange }
enum Green { GreenBlue}
enum Blue {
On Monday, July 15, 2013 13:02:54 Manfred Nowak wrote:
Jonathan M Davis wrote:
Under what circumstances would they not be the same thing?
http://dlang.org/statement.html#GotoStatement
At least the famous gots can make lexical ordering different to
executional ordering.
Well, what that
On Monday, 15 July 2013 at 11:46:54 UTC, Namespace wrote:
int[] arr = new int[sizeOfItems];
Did you also try int[] arr = new int[](sizeOfItems)?
Jonathan M Davis wrote:
gotos in such a context seem like a bit
of a nightmare to me though.
I did realize this nightmare. Therefore the assurance in the docs
is probably true only in the absence within the scope of at least
gotos to targets within the scope.
-manfred
On Monday, 15 July 2013 at 12:23:21 UTC, Adam D. Ruppe wrote:
On Monday, 15 July 2013 at 11:46:54 UTC, Namespace wrote:
int[] arr = new int[sizeOfItems];
Did you also try int[] arr = new int[](sizeOfItems)?
Example code:
void main()
{
int[] arr1 = new int[512];
On Monday, 15 July 2013 at 11:00:59 UTC, Dicebot wrote:
On Monday, 15 July 2013 at 04:24:59 UTC, JS wrote:
...
I think closest solution you can get is having bunch of private
enum definitions and combining them into single public one via
compile-time reflection. Something like
On Monday, 15 July 2013 at 13:01:05 UTC, JS wrote:
...
I see. No, unfortunately, I am currently not aware of a way to
make symbol act as type and and value at the same time.
However it is worth noting that you use plenty of excessive
attributes. Currently it is not a compiler error but
On Sunday, 14 July 2013 at 21:10:53 UTC, Ellery Newcomer wrote:
On 07/11/2013 05:58 AM, Chris wrote:
I have a DLL written in D I load into a Python application via
ctypes
like so:
lib = CDLL(mydll)
The DLL loads and can be used no problem. However, once the
DLL is
discarded of by the
Another question:
I have this code:
void main() {
int* ptr = cast(int*) malloc(11 * int.sizeof);
int[] arr = ptr[0 .. 11];
assert(arr.ptr is ptr);
arr ~= 42;
assert(ptr !is arr.ptr);
}
Is it possible to prohibit that the slice is resized, to
Why does isMutable and isAssignable return true for a
struct/class that are immutable?
immutable struct A { }
isMutable!A returns true.
Namespace:
Is it possible to prohibit that the slice is resized, to avoid
GC allocations?
For that I think you need to define a struct that disables the
append and uses an alias this. But then some of your array
function argument signatures need to change, because lot of D
code uses raw
On Monday, 15 July 2013 at 14:50:04 UTC, JS wrote:
Why does isMutable and isAssignable return true for a
struct/class that are immutable?
immutable struct A { }
isMutable!A returns true.
looks like
immutable struct A
{
int a;
}
acts as a
struct A
{
immutable:
int a;
}
On 07/15/2013 07:18 AM, Chris wrote:
doesn't work with newer versions of dmd
does too. (I'm the maintainer)
https://bitbucket.org/ariovistus/pyd
On Monday, 15 July 2013 at 13:13:42 UTC, bearophile wrote:
Output:
512 1019
512 1019
512 0
But that (of new arrays) is a bad design, it wastes too much
memory, and I think it should be fixed. In Python this doesn't
overallocate:
So what? The only thing you showed, is that
monarch_dodra:
But that (of new arrays) is a bad design, it wastes too much
memory, and I think it should be fixed. In Python this doesn't
overallocate:
So what? The only thing you showed, is that
minimallyInitialized doesn't know how much it allocated. If you
allocate 513 elements with
On Monday, 15 July 2013 at 15:26:49 UTC, Ellery Newcomer wrote:
On 07/15/2013 07:18 AM, Chris wrote:
doesn't work with newer versions of dmd
does too. (I'm the maintainer)
https://bitbucket.org/ariovistus/pyd
Thank you very much (I used an old version of pyd I had found at
On Monday, 15 July 2013 at 15:08:58 UTC, Dicebot wrote:
On Monday, 15 July 2013 at 14:50:04 UTC, JS wrote:
Why does isMutable and isAssignable return true for a
struct/class that are immutable?
immutable struct A { }
isMutable!A returns true.
looks like
immutable struct A
{
int a;
}
unfortunately, dmd doesn't accept the signature as a valid property.
import std.stdio;
import std.typecons;
struct T {
int _i;
@property int i(Nullable!int derp = Nullable!int.init) {
return _i = derp.isNull ? _i : derp.get;
}
}
void main () {
T t;
t.i = 1;
On Monday, 15 July 2013 at 15:59:44 UTC, JS wrote:
On Monday, 15 July 2013 at 15:08:58 UTC, Dicebot wrote:
On Monday, 15 July 2013 at 14:50:04 UTC, JS wrote:
Why does isMutable and isAssignable return true for a
struct/class that are immutable?
immutable struct A { }
isMutable!A returns
https://code.google.com/p/simplefilewatcher/
may help with platform specific solutions.
On Thursday, 23 May 2013 at 18:56:41 UTC, Gary Willoughby wrote:
Hmmm.. this is what i first thought. I think i'll implement a
simple watcher based on modification times as a first
iteration. Then if time
On Monday, 15 July 2013 at 15:54:57 UTC, bearophile wrote:
monarch_dodra:
But that (of new arrays) is a bad design, it wastes too much
memory, and I think it should be fixed. In Python this
doesn't overallocate:
So what? The only thing you showed, is that
minimallyInitialized doesn't know
On Mon, Jul 15, 2013 at 07:32:37PM +0200, monarch_dodra wrote:
On Monday, 15 July 2013 at 15:54:57 UTC, bearophile wrote:
monarch_dodra:
But that (of new arrays) is a bad design, it wastes too much
memory, and I think it should be fixed. In Python this doesn't
overallocate:
So what? The
On Monday, 15 July 2013 at 16:17:02 UTC, John Colvin wrote:
On Monday, 15 July 2013 at 15:59:44 UTC, JS wrote:
On Monday, 15 July 2013 at 15:08:58 UTC, Dicebot wrote:
On Monday, 15 July 2013 at 14:50:04 UTC, JS wrote:
Why does isMutable and isAssignable return true for a
struct/class that are
15-Jul-2013 14:21, Larry пишет:
Humm,
A copy-paste of your code lead to :
[[segmentation
fault
So it doesn't work for me.
I use gdc if it might help !
It looks like a _very_ old GDC. What's you
No. *EVEN* with an ugly malloc, you'll still over allocate
(see above).
int* ptr = cast(int*) malloc(513 * int.sizeof);
int[] arr = ptr[0 .. 513];
writeln(arr.length, ::, arr.capacity);
Output:
513::0
Where is the over allocation?
On Monday, 15 July 2013 at 18:16:45 UTC, Namespace wrote:
writeln(arr.length, ::, arr.capacity);
arr.capacity checks the GC block, and since you malloced it,
there is no gc block for it to check. So it simply doesn't know
if there's any extra capacity there and reports 0 just to be safe.
On Monday, 15 July 2013 at 13:47:10 UTC, Dicebot wrote:
On Monday, 15 July 2013 at 13:01:05 UTC, JS wrote:
...
I see. No, unfortunately, I am currently not aware of a way to
make symbol act as type and and value at the same time.
However it is worth noting that you use plenty of excessive
On Monday, 15 July 2013 at 15:08:58 UTC, Dicebot wrote:
On Monday, 15 July 2013 at 14:50:04 UTC, JS wrote:
Why does isMutable and isAssignable return true for a
struct/class that are immutable?
immutable struct A { }
isMutable!A returns true.
looks like
immutable struct A
{
int a;
}
On Monday, 15 July 2013 at 18:39:08 UTC, JS wrote:
and immutability doesn't nest. immutable struct A { struct B {
}}, struct B is mutable.
What I have meant by may be intended behavior is that immutable
qualifier does not attach at aggregate definitions. At all. It is
irrelevant to the fact
On Monday, 15 July 2013 at 18:56:38 UTC, Gary Willoughby wrote:
Are the two above class declarations achieving the same thing?
i.e. is the type hint of the second snippet shorthand for the
first's 'if'? If so which is preferred?
No, : stands for same or implicitly convertible while == is
On Monday, 15 July 2013 at 18:26:26 UTC, JS wrote:
Original I had it as a class. I'm not sure if it matters much
between a class and a struct though?
It does matter a lot. structs are value types, classes are
polymorphic reference types. There is a nice summary table in
docs:
On Monday, 15 July 2013 at 18:29:12 UTC, Adam D. Ruppe wrote:
On Monday, 15 July 2013 at 18:16:45 UTC, Namespace wrote:
writeln(arr.length, ::, arr.capacity);
arr.capacity checks the GC block, and since you malloced it,
there is no gc block for it to check. So it simply doesn't know
if
On 07/15/2013 12:53 PM, Namespace wrote:
But anyway malloc allocates exact N elements, without ugly overhead.
I doubt it. If its allocating from a bucket, then what actually gets
used is the size of that bucket.
Ali
On Mon, Jul 15, 2013 at 09:53:32PM +0200, Namespace wrote:
On Monday, 15 July 2013 at 18:29:12 UTC, Adam D. Ruppe wrote:
On Monday, 15 July 2013 at 18:16:45 UTC, Namespace wrote:
writeln(arr.length, ::, arr.capacity);
arr.capacity checks the GC block, and since you malloced it, there
is no
Hello all,
Quick query -- what's the preferred template variable name for a range type?
I've seen both R and Range used as options but want to confirm if there's a
preference for one or the other. It occurs to me that Range might potentially
clash with some library or user-created entity.
On Tue, Jul 16, 2013 at 12:52:21AM +0200, Joseph Rushton Wakeling wrote:
Hello all,
Quick query -- what's the preferred template variable name for a range type?
I've seen both R and Range used as options but want to confirm if there's a
preference for one or the other. It occurs to me
On 07/16/2013 01:02 AM, H. S. Teoh wrote:
I generally use R 'cos it's less typing and I'm lazy
... ditto ... :-)
but Walter has been recently of the opinion that a more descriptive name
is necessary for ddoc purposes, e.g., MyStruct(InputRange)(InputRange r)
is much more self-documenting
On Mon, Jul 15, 2013 at 4:02 PM, H. S. Teoh hst...@quickfur.ath.cx wrote:
On Tue, Jul 16, 2013 at 12:52:21AM +0200, Joseph Rushton Wakeling wrote:
Hello all,
Quick query -- what's the preferred template variable name for a range
type?
I've seen both R and Range used as options but
On Monday, July 15, 2013 14:48:08 Manfred Nowak wrote:
Jonathan M Davis wrote:
gotos in such a context seem like a bit
of a nightmare to me though.
I did realize this nightmare. Therefore the assurance in the docs
is probably true only in the absence within the scope of at least
gotos to
On Mon, Jul 15, 2013 at 08:59:44PM -0400, Jonathan M Davis wrote:
On Monday, July 15, 2013 14:48:08 Manfred Nowak wrote:
Jonathan M Davis wrote:
gotos in such a context seem like a bit
of a nightmare to me though.
I did realize this nightmare. Therefore the assurance in the docs
is
On Monday, July 15, 2013 21:08:03 Dicebot wrote:
On Monday, 15 July 2013 at 18:39:08 UTC, JS wrote:
and immutability doesn't nest. immutable struct A { struct B {
}}, struct B is mutable.
What I have meant by may be intended behavior is that immutable
qualifier does not attach at
On Tuesday, July 16, 2013 03:46:06 JS wrote:
On Tuesday, 16 July 2013 at 01:24:37 UTC, Jonathan M Davis wrote:
On Monday, July 15, 2013 21:08:03 Dicebot wrote:
On Monday, 15 July 2013 at 18:39:08 UTC, JS wrote:
and immutability doesn't nest. immutable struct A { struct B
{
}}, struct
On 07/15/2013 07:50 AM, JS wrote:
Why does isMutable and isAssignable return true for a struct/class that
are immutable?
immutable struct A { }
isMutable!A returns true.
import std.traits;
struct S
{}
alias ImmutableS = immutable(S);
void main()
{
static
http://dpaste.dzfl.pl/7c8b0ba9
Why the heck can't we use integers in ctfe's? There seems to be
no simple way to create a counter and this is one of the most
basic programming constructs to use.. yet with ctfe's it's
impossible.
I'd like each variable in the nested structs to be incremented
On 07/15/2013 08:43 PM, JS wrote:
http://dpaste.dzfl.pl/7c8b0ba9
Why the heck can't we use integers in ctfe's? There seems to be no
simple way to create a counter and this is one of the most basic
programming constructs to use.. yet with ctfe's it's impossible.
I'd like each variable in
On Tuesday, 16 July 2013 at 04:37:33 UTC, Ali Çehreli wrote:
On 07/15/2013 08:43 PM, JS wrote:
http://dpaste.dzfl.pl/7c8b0ba9
Why the heck can't we use integers in ctfe's? There seems to
be no
simple way to create a counter and this is one of the most
basic
programming constructs to use..
58 matches
Mail list logo