Re: Isn't using find with retro awkward?

2011-02-14 Thread Jonathan M Davis
On Monday 14 February 2011 21:14:18 Andrej Mitrovic wrote: > On 2/15/11, Jonathan M Davis wrote: > > Of _course_ you get a reversed range back. You _reversed the range_. > > That's what > > retro _does_. If you use it with find, of _course_ you're going to get a > > reversed > > range back. Compla

Re: Isn't using find with retro awkward?

2011-02-14 Thread Andrej Mitrovic
On 2/15/11, Jonathan M Davis wrote: > > Of _course_ you get a reversed range back. You _reversed the range_. That's > what > retro _does_. If you use it with find, of _course_ you're going to get a > reversed > range back. Complaining about that is like complaining that your range is > sorted > af

Re: Isn't using find with retro awkward?

2011-02-14 Thread Jonathan M Davis
On Monday 14 February 2011 20:40:02 Andrej Mitrovic wrote: > On 2/15/11, Jonathan M Davis wrote: > > retro revereses the whole range. What you want is something like > > findFromBack. > > I don't think that we have any functions like findFromBack though. It's > > probably > > worth an enhancement

Re: Isn't using find with retro awkward?

2011-02-14 Thread Andrej Mitrovic
On 2/15/11, Jonathan M Davis wrote: > > retro revereses the whole range. What you want is something like > findFromBack. > I don't think that we have any functions like findFromBack though. It's > probably > worth an enhancement request. std.string had a find and rfind, both of which are deprecat

Re: Isn't using find with retro awkward?

2011-02-14 Thread Jonathan M Davis
On Monday 14 February 2011 19:35:21 Andrej Mitrovic wrote: > import std.stdio, std.algorithm, std.range; > > void main() > { > writeln( find([5, 1, 2, 3, 4, 5, 1], 5) ); > writeln( find(retro([5, 1, 2, 3, 4, 5, 1]), 5) ); > } > > Output: > [5, 1, 2, 3, 4, 5, 1] > [5, 4, 3, 2, 1, 5] > > T

Re: Array types not treated uniformly when passed as ranges

2011-02-14 Thread Jonathan M Davis
On Monday 14 February 2011 18:18:39 jam wrote: > Hi all, > > Just curious as to the difference in the built-in variable length > array vs. the std.container.Array and fixed length arrays when it > comes to using them in functions that take Ranges. > > For instance the following does not compile:

Isn't using find with retro awkward?

2011-02-14 Thread Andrej Mitrovic
import std.stdio, std.algorithm, std.range; void main() { writeln( find([5, 1, 2, 3, 4, 5, 1], 5) ); writeln( find(retro([5, 1, 2, 3, 4, 5, 1]), 5) ); } Output: [5, 1, 2, 3, 4, 5, 1] [5, 4, 3, 2, 1, 5] The docs for find are: "returns : haystack advanced such that binaryFun!pred(haystack.

Array types not treated uniformly when passed as ranges

2011-02-14 Thread jam
Hi all, Just curious as to the difference in the built-in variable length array vs. the std.container.Array and fixed length arrays when it comes to using them in functions that take Ranges. For instance the following does not compile: import std.algorithm; import std.stdio; import std.range; im

Re: Context-Free Grammars? What about arrays?

2011-02-14 Thread Nick Sabalausky
"%u" wrote in message news:ij3la9$t53$1...@digitalmars.com... > > Again, just because the AST's _happen_ to _look_ the same for static and > associative arrays, does that mean that this makes D context-free? Grammar is *just* about how it *looks*, not what it means. > The meaning of > the expre

Defult stack size on Windows?

2011-02-14 Thread Nick Sabalausky
Anyone know what DMD/OPTLINK's default stack size on windows is? Or how to find out? Also, I don't suppose there's a way to give a linker flag to DMD that it'll simply ignore on non-Windows platforms, is there? --- Not sent from an iPhone.

Re: Context-Free Grammars? What about arrays?

2011-02-14 Thread Nick Sabalausky
"%u" wrote in message news:ij3la9$t53$1...@digitalmars.com... > > The problem is that it _is_ ambiguous what rule to apply. To me, just > because > static arrays and associative arrays happen to have similar _looks_ > doesn't make > parsing them context-free -- they're defined with completely s

Re: AA insertion order iteration

2011-02-14 Thread Steven Schveighoffer
On Mon, 14 Feb 2011 16:39:24 -0500, spir wrote: On 02/14/2011 03:27 PM, Steven Schveighoffer wrote: On Mon, 14 Feb 2011 06:31:25 -0500, spir wrote: Hello, How would you wrap an AA to allow memorising insertion order, and be able to use it for iteration? * Indeed, one could store keys i

Re: AA insertion order iteration

2011-02-14 Thread spir
On 02/14/2011 03:27 PM, Steven Schveighoffer wrote: On Mon, 14 Feb 2011 06:31:25 -0500, spir wrote: Hello, How would you wrap an AA to allow memorising insertion order, and be able to use it for iteration? * Indeed, one could store keys in a // (ordered) array. But this means iteration requi

Re: traits: how to split parametrized type into basic type and parameters

2011-02-14 Thread Philippe Sigaud
On Mon, Feb 14, 2011 at 22:09, Martin Kinkelin wrote: > So from the outside, components are accessed either via indexing or > via x,y,z and w (analog to HLSL/GLSL). I also added some downcasting > shortcuts via properties, e.g.: > > auto f4 = float4(1,2,3,4); > auto r = f4.xyz + 2.0; // downcast

Re: traits: how to split parametrized type into basic type and parameters

2011-02-14 Thread Martin Kinkelin
> Did you try without the cast? Since we know that _data components can > be cast to r._data elements, the compiler should take care of that for > you. Nope, I didn't try that because, for instance, floats shouldn't be implicitly castable to ints. > You can also use cast(float2) f3 to get rid of

Re: Number of references to a Class Object

2011-02-14 Thread spir
On 02/14/2011 03:34 PM, Stanislav Blinov wrote: 12.02.2011 18:44, d coder пишет: Also tango (for D 1.0) implements it. Link: http://www.dsource.org/projects/tango/docs/current/tango.core.WeakRef.html Might be worth a look if you are going to implement it for D 2.0. I looked at the D1 implemen

Re: exit() to end a function

2011-02-14 Thread spir
On 02/14/2011 05:39 PM, Steven Schveighoffer wrote: On Mon, 14 Feb 2011 11:19:24 -0500, Jonathan M Davis wrote: On Monday 14 February 2011 06:12:56 Steven Schveighoffer wrote: On Sat, 12 Feb 2011 17:48:56 -0500, Jonathan M Davis wrote: > There would be some value to having an attribute whi

Re: Inheritance problem

2011-02-14 Thread spir
On 02/14/2011 05:13 PM, Steven Schveighoffer wrote: The theory for the private access in a module goes that likely the same author wrote all the code in that module, so he should understand what the code is supposed to do and have free access to anything. It seems to work pretty well in practice

Re: exit() to end a function

2011-02-14 Thread Steven Schveighoffer
On Mon, 14 Feb 2011 11:19:24 -0500, Jonathan M Davis wrote: On Monday 14 February 2011 06:12:56 Steven Schveighoffer wrote: On Sat, 12 Feb 2011 17:48:56 -0500, Jonathan M Davis wrote: > There would be some value to having an attribute which indicated that a > function > never returns

Re: Inheritance problem

2011-02-14 Thread Andrej Mitrovic
On 2/14/11, Steven Schveighoffer wrote: > In C++ a friend function is able to access all private > data. The most common use of friend functions is for output stream > processors (since the operator is on the stream and not the object being > outputted). Oh right, these << << <

Re: exit() to end a function

2011-02-14 Thread Jonathan M Davis
On Monday 14 February 2011 06:12:56 Steven Schveighoffer wrote: > On Sat, 12 Feb 2011 17:48:56 -0500, Jonathan M Davis > > wrote: > > There would be some value to having an attribute which indicated that a > > function > > never returns under any circumstances (likely since it always throws), > >

Re: Inheritance problem

2011-02-14 Thread Steven Schveighoffer
On Mon, 14 Feb 2011 10:52:41 -0500, Andrej Mitrovic wrote: On 2/14/11, Steven Schveighoffer wrote: What's wrong with: class Foo { private int _x, _y; this(int x, int y) { _x = x; _y = y; } int sumXY() { return _x + _y; } } Nothing! But

Re: Inheritance problem

2011-02-14 Thread Andrej Mitrovic
On 2/14/11, Steven Schveighoffer wrote: > What's wrong with: > > class Foo { > private int _x, _y; > this(int x, int y) { > _x = x; > _y = y; > } > int sumXY() { > return _x + _y; > } > } Nothing! But the OP asked why it's possible to access the

Re: ref vs out.

2011-02-14 Thread Stanislav Blinov
14.02.2011 18:06, Charles McAnany пишет: Hi, all. So I'm new to this whole contract thing. (I'm coming from C and Java.) I got the impression that using foo(out arg) means that arg is given its default value, but other than that it's just like ref. So, here's the basic code I have thus far. 01 i

Re: ref vs out.

2011-02-14 Thread Jesse Phillips
Charles McAnany Wrote: > Hi, all. So I'm new to this whole contract thing. (I'm coming from C and > Java.) > I got the impression that using foo(out arg) means that arg is given its > default value, but other than that it's just like ref. So, here's the basic > code I have thus far. The init val

ref vs out.

2011-02-14 Thread Charles McAnany
Hi, all. So I'm new to this whole contract thing. (I'm coming from C and Java.) I got the impression that using foo(out arg) means that arg is given its default value, but other than that it's just like ref. So, here's the basic code I have thus far. 01 import std.random:Random; 02 import std.cont

Re: std.concurrency & immutable classes...

2011-02-14 Thread Steven Schveighoffer
On Fri, 11 Feb 2011 17:08:26 -0500, Tomek Sowiński wrote: Steven Schveighoffer napisał: > It would be much easier if he provided the specific case(s) which broke > his teeth. Then we'll all know where's the problem. If it's soluble, > it'll open the door to tail type modifiers in general, n

Re: using a binary tree container

2011-02-14 Thread Steven Schveighoffer
On Sun, 13 Feb 2011 09:29:14 -0500, Lutger Blijdestijn wrote: Dominic Jones wrote: Hello, I have a list of strings and I want to determine whether or not a particular string in the is in that list. Assuming I should store the list of strings in a binary tree to facilitate fast searching,

Re: Number of references to a Class Object

2011-02-14 Thread Stanislav Blinov
12.02.2011 18:44, d coder пишет: Also tango (for D 1.0) implements it. Link: http://www.dsource.org/projects/tango/docs/current/tango.core.WeakRef.html Might be worth a look if you are going to implement it for D 2.0. I looked at the D1 implementation. It depends on GC methods weakPointerCreat

Re: AA insertion order iteration

2011-02-14 Thread Steven Schveighoffer
On Mon, 14 Feb 2011 06:31:25 -0500, spir wrote: Hello, How would you wrap an AA to allow memorising insertion order, and be able to use it for iteration? * Indeed, one could store keys in a // (ordered) array. But this means iteration requires a series of lookups by key. * A slightly bette

Re: Opt-out polymorphism?

2011-02-14 Thread Steven Schveighoffer
On Sun, 13 Feb 2011 16:34:04 -0500, Sean Eskapp wrote: Is there a way to specify that a function is nonvirtual, but can still be "overriden" in base classes? e.g. class A { void foo() { writeln("A"); } } class B : A { void foo() { writeln("B"); } } v

Re: exit() to end a function

2011-02-14 Thread spir
On 02/14/2011 03:12 PM, Steven Schveighoffer wrote: On Sat, 12 Feb 2011 17:48:56 -0500, Jonathan M Davis wrote: There would be some value to having an attribute which indicated that a function never returns under any circumstances (likely since it always throws), but that wouldn't help exit a

Re: Error: this for ~this needs to be type foo not type foo[1u][1u]

2011-02-14 Thread Steven Schveighoffer
On Sun, 13 Feb 2011 09:33:40 -0500, d coder wrote: Greetings I am getting this error when I am instantiating a struct array with a single element inside another class and only if there is the destructor for the struct is explicitly defined. Is it a known error? Here is a minimized snippet that

Re: exit() to end a function

2011-02-14 Thread Steven Schveighoffer
On Sat, 12 Feb 2011 17:48:56 -0500, Jonathan M Davis wrote: There would be some value to having an attribute which indicated that a function never returns under any circumstances (likely since it always throws), but that wouldn't help exit any, since it's a C function and wouldn't have the

Re: Number of references to a Class Object

2011-02-14 Thread Steven Schveighoffer
On Sat, 12 Feb 2011 12:02:14 -0500, Jonathan M Davis wrote: On Saturday 12 February 2011 08:45:03 d coder wrote: > If you know roughly what to do and want to take a stab at producing a > viable patch to fix the problem, then feel free. If it's solid, it may > get in. I don't know. It doesn't

Re: Inheritance problem

2011-02-14 Thread Steven Schveighoffer
On Fri, 11 Feb 2011 17:26:29 -0500, Andrej Mitrovic wrote: On 2/11/11, bearophile wrote: Steven Schveighoffer: Any code can access any members defined in the current module, regardless of access attributes I am not sure if Walter understands how much this rule makes it hard for peopl

Re: traits: how to split parametrized type into basic type and parameters

2011-02-14 Thread Philippe Sigaud
On Mon, Feb 14, 2011 at 13:09, Martin Kinkelin wrote: > Hi Philippe, > > thank you very much! You're welcome. > I added your isVector!T template as well as the two aliases. > opCast!NewType is implemented like this: > > V opCast(V)() if (isVector!V) > // parameters {d2,T2} of V are checked when

Re: traits: how to split parametrized type into basic type and parameters

2011-02-14 Thread Martin Kinkelin
Hi Philippe, thank you very much! I added your isVector!T template as well as the two aliases. opCast!NewType is implemented like this: V opCast(V)() if (isVector!V) // parameters {d2,T2} of V are checked when instantiating V: d2 >= 1 && isNumeric!T2 { V r; foreach (i; 0 .. (d < V.dim ?

AA insertion order iteration

2011-02-14 Thread spir
Hello, How would you wrap an AA to allow memorising insertion order, and be able to use it for iteration? * Indeed, one could store keys in a // (ordered) array. But this means iteration requires a series of lookups by key. * A slightly better method would be to store hash values, which anyway

Re: traits: how to split parametrized type into basic type and parameters

2011-02-14 Thread Philippe Sigaud
Hi Martin, > I'm implementing a generic Vector!(uint d, T) struct (wrapping a T[d] array). > For readability: > alias Vector!(4u,float) float4; > alias Vector!(4u,int)   int4; > > I'd like to be able to cast a float4 variable explicitly to an int4 > (component-wise casting): > auto f4 = float4(1,2