Curl Module Error

2013-07-11 Thread Ali
I get an error message when trying to curl Error output: root@02x110:~/Desktop# gdc a.d -o a a.d:2: Error: module curl is in file 'std/net/curl.d' which cannot be read import path[0] = /usr/include/d2/4.6/i486-linux-gnu import path[1] = /usr/include/d2/4.6 My Code: import std.net.curl; impor

Re: Curl Module Error

2013-07-11 Thread Ali
On Thursday, 11 July 2013 at 13:46:48 UTC, Johannes Pfau wrote: Am Thu, 11 Jul 2013 15:29:09 +0200 schrieb "Ali" : /usr/include/d2/4.6 This looks like you're using a very old gdc version. std.net.curl was added in 2.058. How do I update? Searched, but could not find it.

Re: Curl Module Error

2013-07-11 Thread Ali
On Thursday, 11 July 2013 at 14:44:23 UTC, H. S. Teoh wrote: On Thu, Jul 11, 2013 at 04:36:42PM +0200, Ali wrote: On Thursday, 11 July 2013 at 13:46:48 UTC, Johannes Pfau wrote: >Am Thu, 11 Jul 2013 15:29:09 +0200 >schrieb "Ali" : > >>/usr/include/d2/4.6 > >This

Re: Foreach with byte problems

2011-02-25 Thread Ali Çehreli
ut the better solution before sending this message: foreach (e; __traits(allMembers, E)) { writeln(e); } The difference is, the type of 'e' is string above. Finally, the following produces integer values: foreach (e; __traits(allMembers, E)) { writeln(to!E(e)); } Ok, good... :) Ali

Re: Multiple assignment

2011-02-25 Thread Ali Çehreli
ere, separating (and sequencing) two expressions: 1) i 2) x[i] = 1 > assert(x == [1, 0]); // OK > > int j; > int[2] y; > y[j], j = 1; Again, two expressions: 1) y[j] 2) j = 1 Only the second of both cases have an effect. Ali > assert(y == [0, 0]); // No

Re: Multiple assignment

2011-02-25 Thread Ali Çehreli
On 02/25/2011 05:09 PM, bearophile wrote: > int j; > int[2] y; > y[j] = j = 1; I think that's undefined behavior in C and C++. It is not defined whether j's previous or past value is used in y[j]. I would expect the situation be the same in D. Ali

Re: Multiple assignment

2011-02-25 Thread Ali Çehreli
On 02/25/2011 06:10 PM, Jonathan M Davis wrote: On Friday, February 25, 2011 17:31:36 Ali Çehreli wrote: On 02/25/2011 05:09 PM, bearophile wrote: > int j; > int[2] y; > y[j] = j = 1; I think that's undefined behavior in C and C++. It is not defined whethe

Re: Template argument deduction

2011-02-28 Thread Ali Çehreli
first instantiation? Thanks in advance, Tom; That's because the type of literals like [1, 2] are slices (dynamic arrays), not fixed-sized arrays. import std.stdio; void main() { writeln(typeof([1,2]).stringof); } The output of that program is int[] Ali

Re: Template argument deduction

2011-03-01 Thread Ali Çehreli
3/01/2011 04:30 AM, bearophile wrote: > Ali Çehreli: > >> That's because the type of literals like [1, 2] are slices (dynamic >> arrays), not fixed-sized arrays. > > Then why is this accepted? > > foo!int([[1,2],[3,4],[5,6]]); // OK If I have to guess, I think sup

Re: Parameterized Structs

2011-03-02 Thread Ali Çehreli
an be very powerful: http://digitalmars.com/d/2.0/template.html#TemplateAliasParameter Ali

Re: Struct reference returning function and const members

2011-03-02 Thread Ali Çehreli
stMember(1, new C); // now compiles } Ali

Re: Parameterized Structs

2011-03-02 Thread Ali Çehreli
On 03/02/2011 11:11 PM, Peter Lundgren wrote: > == Quote from Ali Çehreli (acehr...@yahoo.com)'s article >> On 03/02/2011 08:56 PM, Peter Lundgren wrote: >>> Where can I go to learn about parameterized structs? I can't seem to find any >>> literature on the

Re: Parameterized Structs

2011-03-03 Thread Ali Çehreli
statically initialized at compile time, and the value argument can be any expression which can be evaluated at compile time. This includes integers, floating point types, and strings. Ali

Re: Parameterized Structs

2011-03-03 Thread Ali Çehreli
On 03/03/2011 03:25 AM, bearophile wrote: Ali Çehreli: Template value parameter types can be any type which can be statically initialized at compile time, and the value argument can be any expression which can be evaluated at compile time. This includes integers, floating point types, and

Re: Overriding "in" operator

2011-03-04 Thread Ali Çehreli
Huh. Cool. Works like a charm. Seems cleaner like the opBinaryRight solution, really. I just didn't know of it :) It can be seen on the D1 documentation: http://www.digitalmars.com/d/1.0/operatoroverloading.html That is (or "will be") deprecated in D2. Ali

Re: using enums as key in associative array

2011-03-07 Thread Ali Çehreli
eviceType] execDeviceSuffix; > > static this() > { >execDeviceSuffix[deviceType.cpu] = "cpu"; >execDeviceSuffix[deviceType.gpu] = "gpu"; > } This works too: static this() { execDeviceSuffix = [deviceType.cpu:".cpu", deviceType.gpu:".gpu"]; } Ali

Re: std.traits and std.string incompatible ?

2011-03-08 Thread Ali Çehreli
compile time: static if (isNumeric!SomeType) It doesn't work with string values. Although unnecessary, you could do this: bool test = isNumeric!(typeof(args[0])); Ali

Re: Dynamic array void initialization

2011-03-08 Thread Ali Çehreli
ou want to confuse yourself (and me): ss.reserve(5); // same thing as above foreach (ref s; ss) s = S(1, 2); return 0; } Ali

Re: Dynamic array void initialization

2011-03-08 Thread Ali Çehreli
On 03/08/2011 02:03 PM, Steven Schveighoffer wrote: > it's not std.array.reserve, it's object.reserve, always present, no need > to import. Thanks. The reserve that I found in array.d is std.array.Appender(T).reserve. Ali

Re: Read file/stream

2011-03-11 Thread Ali Çehreli
{ return value << 24 | (value & 0xFF00) << 8 | (value & 0x00FF) >> 8 | value >> 24; } } There is also std.intrinsic.bswap Ali though you would have to remember to call it for each file I/O operation that relies on it. If you use a struct, you could

Re: Fibonacci with ranges

2011-03-12 Thread Ali Çehreli
ke(recurrence!("a[n-1] + a[n-2]")(0L, 1L), n); } void main() { long[] data = [ 0, 1, 1, 2, 3, 5, 8 ]; foreach (n; 0 .. data.length) { assert(equal(declarative(n), data[0..n])); } } Ali

Re: struct construct with array

2011-03-12 Thread Ali Çehreli
ollar] not implemented The following doesn't work either: auto result = v1[] + v2[]; auto result = v1 + v2; dmd does not implement those features yet. Ali

Re: struct construct with array

2011-03-12 Thread Ali Çehreli
On 03/12/2011 02:52 PM, Ali Çehreli wrote: On 03/12/2011 10:42 AM, Caligo wrote: struct Test{ public double[3] ar_; this(double[3] ar){ this.ar_ = ar; } } void main(){ double[3] v1 = [1.0, 2.0, 3.0]; double[3] v2 = [2.0, 3.0, 4.0]; auto t1 = Test(v1[0..$] + v2[0..$]); // error } I want

Reading a line from stdin

2011-03-15 Thread Ali Çehreli
name? "); string name = readln(); writeln("Hi ", name, "!"); } The newline character is read as a part of the input: What is your name? Ali Hi Ali ! <-- this is outputted on the next line because of the newline character A solution is to strip the line

Re: Reading a line from stdin

2011-03-16 Thread Ali Çehreli
On 03/16/2011 05:49 AM, Kagamin wrote: Ali ǥhreli Wrote: The following program may be surprising to the novice: import std.stdio; void main() { write("What is your name? "); string name = readln(); writeln("Hi ", name, "!"); } What if the u

Re: Problem with associative arrays

2011-03-19 Thread Ali Çehreli
tr != s0.ptr); assert(s2.ptr != s1.ptr); } I forgot the name of the feature. Basically, no slice (aka dynamic array) can extend into other elements and starts sharing them. Ali

Re: How do I iteratively replace lines in a file?

2011-03-20 Thread Ali Çehreli
he file must have a well defined format. It is not possible to insert or remove bytes from a file due to low level reasons. The file systems that I am aware of don't provide such interfaces. And writing after fseek would overwrite existing data. Like Jonathan M Davis said, the best is to read from the source and write to the destination. Ali

Re: Get single keystroke?

2011-03-21 Thread Ali Çehreli
ks to the C (and C++) heritage, there is no guarantee that there is a keyboard around. The interface is stdin, stdout, and stderr; which are just character streams. But I agree: some subset of ncurses would be nice when a keyboard is available. > > Bye, > bearophile Ali

Re: Get single keystroke?

2011-03-21 Thread Ali Çehreli
tp://groups.google.com/group/comp.os.linux.development.apps/ >> browse_thread/thread/0667d16089e2b6fc >> > > H mentions using tcgetattr to save old state and restoring it with > tcsetattr. This is what this code does. Btw this code is not mine, > Walter posted it and I just added the cfmakeraw prototype. So kudos > goes to him. Thanks for posting this. It can be improved by moving the last tcsetattr to an earlier scope(exit) statement: termios ostate; tcgetattr(1, &ostate); scope (exit) tcsetattr(1, TCSADRAIN, &ostate); Ali

Re: Need help in templates

2011-03-24 Thread Ali Çehreli
somebody please point out the > error of this code? I would really love to look at it but like some other people all I get is the following non-D code. ;) I don't know whether the problem is on my end but e-mail and news used to be easier. :) Ali > begin 644 main.d > M;6]D=6QE(&UA:6X[#0H-"FEM<&]R="!S=&0N M*'-T

Re: Contracts or Exceptions?

2011-03-29 Thread Ali Çehreli
ensible thing to do at that level: log an error, skip that operation, go back to the user with an error code, take corrective action, etc. Disclaimer: That is what I follow in C++ code. I don't have experience with exception safety in D. I don't know issues that may be specific to D. Ali

Re: Contracts or Exceptions?

2011-03-30 Thread Ali Çehreli
> I'm not sure D's exceptions are much different than C++'s. Yeah, it must be the same as what Digital Mars C++ compiler uses. (Except, D also has the 'finally' clause.) In summary: I hope I will never go back to pass-the-error-code style of coding. Ali

Re: Contracts or Exceptions?

2011-03-30 Thread Ali Çehreli
On 03/30/2011 12:40 PM, Jonathan M Davis wrote: On 2011-03-30 05:09, spir wrote: On 03/30/2011 05:32 AM, Ali Çehreli wrote: On 03/29/2011 03:40 PM, Kai Meyer wrote: I was given two words of advice on exceptions: "Use exceptions for the exceptional" "Use exceptio

Re: template template parameter

2011-03-30 Thread Ali Çehreli
rType, T) { // Instantiate the 'template template parameter' ContainerType!T member; } void main() { Foo!(SomeContainer, double) foo1; Foo!(SomeOtherContainer, int) foo2; } ContainerType is a template parameter of Foo and is itself a template. And 'alias' seems to work... Ali

Re: template template parameter

2011-03-31 Thread Ali Çehreli
td.stdio; struct Box(T, int width, int height) { void Fun(T2, int width2, int height2)(Box!(T2, width2, height2) b) { writeln(width2, ' ', height2); } } void main() { auto b1 = Box!(double, 2, 7)(); auto b2 = Box!(double, 3, 4)(); b1.Fun(b2); } Ali

Re: char[][] join ==> string

2011-04-06 Thread Ali Çehreli
iciency of the D GC it's better to reduce memory allocations as much as possible. > Here join() creates a brand new array, so idup performs a useless copy. To avoid this extra copy do I have to write another joinString() function? > > Bye, > bearophile Ali

Re: char[][] join ==> string

2011-04-07 Thread Ali Çehreli
d: immutable(T)[] assumeUnique(T)(ref T[] array) pure nothrow { auto result = cast(immutable(T)[]) array; array = null; return result; } And that fails as join's return type is not an lvalue. We need a simplyAssumeUnique() that doesn't null the reference parameter :); and it would have no value over casting other than communicating the intent. Ali

Re: char[][] join ==> string

2011-04-07 Thread Ali Çehreli
On 04/07/2011 01:04 AM, spir wrote: > On 04/07/2011 09:52 AM, spir wrote: >> On 04/07/2011 03:07 AM, Ali Çehreli wrote: >>>> Given an array of strings std.string.join() returns a single string: >>>> >>>> import std.string; >>>> void mai

Re: Creating stream from stdout

2011-04-23 Thread Ali Çehreli
om D. They are deprecated in favor of a "range" interface. std.range and std.algorithm have examples of ranges that are first introduced in this article (with different names in Phobos): http://www.informit.com/articles/printerfriendly.aspx?p=1407357 Ali

Re: Creating stream from stdout

2011-04-23 Thread Ali Çehreli
mean what is already in D, I mean those streams are gone from D. I shouldn't need to disclaim that some module in the future may be related to streams. 2) Streams that are currently present in D are deprecated in favor of a new interface that will use ranges, or be ranges. 3) The seminal paper that I linked above is it. Ali

Re: Creating stream from stdout

2011-04-24 Thread Ali Çehreli
Linux Programmer's Manual STDIN(3) NAME stdin, stdout, stderr - standard I/O streams SYNOPSIS #include Ali

Re: Polymorphic ranges?

2011-05-01 Thread Ali Çehreli
the case of non-random access ranges. Ali

Re: Polymorphic ranges?

2011-05-01 Thread Ali Çehreli
declaration Limitations are caused by bug, that is going to get fixed eventually ;) Ali

Re: Polymorphic ranges?

2011-05-01 Thread Ali Çehreli
p); count = 0; } Thread.sleep( dur!("msecs")(100) ); } } I hope those bugs get squashed so I can have more fun with these ranges. :) Ali

Re: Getting equivalent elements in a range/array

2011-05-07 Thread Ali Çehreli
On 05/07/2011 09:07 PM, Andrej M. wrote: I want to turn this: auto arr = [1, 1, 2, 3, 4, 4]; into this: auto arr2 = [[1, 1], [2], [3], [4, 4]]; I want an array of arrays of the same elements. Lazy or not, I don't care. I thought I could get away with this inside some while loop: auto equals =

Re: What is the design reasons for Not considering base class overloaded function?

2011-05-24 Thread Ali Çehreli
ue is common. Here, the decision is the safer one. Only when we know what we're doing, we can change this behavior. > If I am not mistaken, in C++/Java. They will choose the most bottom up > closes parameter type signature match. Not in C++. C++ has "name hiding", which hides all of base's functions and members with the same name. Ali

Re: What is the design reasons for Not considering base class overloaded function?

2011-05-25 Thread Ali Çehreli
ve been in a single module. Ali

Re: Any application shutdown hooks?

2011-05-25 Thread Ali Çehreli
top of the page. That is linked to the class page.) Ali

Re: Infinite loop not working DMD2

2011-06-02 Thread Ali Çehreli
On 06/02/2011 08:51 AM, Guillermo Estrada wrote: The exec* family of functions cause the new app to replace the current process. So after the execv, the loop doesn't exist. Any way to spawn the process without killing himself? Would std.process.system or std.process.shell work? Ali

Re: Can't use float array in map

2011-06-03 Thread Ali Çehreli
On 06/03/2011 10:15 AM, Andrej Mitrovic wrote: > Offending line in map: > alias typeof(_fun(.ElementType!R.init)) ElementType; The fact that the error points at that line should be a bug. That's just an alias, nothing is evaluated at that line. Ali

Are spawn'ed threads waited automatically?

2011-06-06 Thread Ali Çehreli
one intermediate done 0 foo 1 foo 2 foo 3 foo 4 foo Is the inconsistency a bug or a natural consequence of something? :) (Perhaps even the first example that seems to run correctly just has a higher probability of showing this behavior.) I am aware of thread_joinAll(). Is that the recommended way of waiting for all threads? Thank you, Ali

Re: Are spawn'ed threads waited automatically?

2011-06-06 Thread Ali Çehreli
On 06/06/2011 12:07 PM, Steven Schveighoffer wrote: On Mon, 06 Jun 2011 14:09:25 -0400, Ali Çehreli wrote: First, the answer may be as simple as "use core.thread.thread_joinAll". Is that the proper way of waiting for all threads? main (the C main, not D main) does this alrea

Re: Are spawn'ed threads waited automatically?

2011-06-06 Thread Ali Çehreli
lts as well: http://d.puremagic.com/issues/show_bug.cgi?id=6116 Ali

Re: Is it reasonable to learn D

2011-06-07 Thread Ali Çehreli
all of the negative feedback that you've listed. Ali

Re: So how exactly does one make a persistent range object?

2011-06-13 Thread Ali Çehreli
.stdio; import std.range; enum a = [1, 2, 3]; auto range = cycle(a[]); void main() { foreach (i; 0 .. 2) { foo(); } } void foo() { foreach(i; 0 .. 5) { writeln(range.front); range.popFront(); } } Ali

Re: Adding a method to an enum.

2011-06-19 Thread Ali Çehreli
nt count = 1) { direction_ += count; direction_ %= Direction.sizeof; } void rotateLeft(int count = 1) { rotateRight(-count); } @property Direction direction() const { return direction_; } } Ali

Implicit conversion of unique objects to mutable and immutable

2011-06-21 Thread Ali Çehreli
But anyway... How do you solve the problem of deciding the return type of such functions? Thank you, Ali

Re: Implicit conversion of unique objects to mutable and immutable

2011-06-21 Thread Ali Çehreli
On Tue, 21 Jun 2011 23:02:43 +, Jonathan M Davis wrote: > On 2011-06-21 15:25, Ali Çehreli wrote: >> (Note: I have a feeling that this must be related to the old 'unique' >> discussions, which I had somehow managed to stay out of. If so, I >> apologize for rep

Re: Implicit conversion of unique objects to mutable and immutable

2011-06-21 Thread Ali Çehreli
On Tue, 21 Jun 2011 19:04:11 -0400, bearophile wrote: > Ali Çehreli: > >> char[] result = foo(); >> string immutable_result = assumeUnique(result); >> >> But that's the wrong thing to do, as foo() may be changed in the future >> to return a non

Re: Implicit conversion of unique objects to mutable and immutable

2011-06-21 Thread Ali Çehreli
he function returns string > rather than char[]. No. In the above code there is no need for a copy because the returned string is actually mutable. But the caller must make a copy because of not being certain whether the returned string is really mutable or immutable. > - Jonathan M Davis Ali

Re: Implicit conversion of unique objects to mutable and immutable

2011-06-21 Thread Ali Çehreli
On Wed, 22 Jun 2011 00:02:55 +, Ali Çehreli wrote: > I wonder whether a UniqueRef object could be returned, which could allow > a single casting of its data to mutable or immutable at the call site. > Further casts could throw, but that would be a runtime solution. :-/ An extrem

Re: readf with strings

2011-06-22 Thread Ali Çehreli
ring; void main() { float MyFloat; readf(" %s", &MyFloat); writeln(MyFloat); readf(" "); string MyString = chomp(readln()); writeln(MyString); } Ali

Re: Implicit conversion of unique objects to mutable and immutable

2011-06-22 Thread Ali Çehreli
On Wed, 22 Jun 2011 15:58:02 +, Timon Gehr wrote: > On Wed, 22 Jun 2011 00:02:55 +0000, Ali Çehreli wrote: > >> I wonder whether a UniqueRef object could be returned, which could >> allow a single casting of its data to mutable or immutable at the call >> site. Furthe

Re: An effort at creating a free ebook for learning D

2011-06-22 Thread Ali Çehreli
27; always means "new line" to be replaced with each platform's correct code sequence. Ali

Re: readf with strings

2011-06-22 Thread Ali Çehreli
is that is being (is?) deprecated. It reads simpler like writeln: import std.cstream; void main() { double d; int i; din.readf(&d, &i); dout.writefln("d: %s, i: %s", d, i); } It would still be problematic with strings. How many characters should be a part of it? Ali

Re: readf with strings

2011-06-22 Thread Ali Çehreli
;oku" means "read": // Read into an existing variable double d; oku("Please enter a double: ", &d); // Read and return a value int i = oku!int("Please enter an int: "); Ali

Re: readf with strings

2011-06-22 Thread Ali Çehreli
On Wed, 22 Jun 2011 13:45:56 -0500, Jimmy Cao wrote: > On Wed, Jun 22, 2011 at 1:31 PM, Ali Çehreli wrote: > >> On Wed, 22 Jun 2011 20:17:39 +0200, Andrej Mitrovic wrote: >> >> > This library has some nice user-input methods for D2: >> > https://github

Re: WTF! Parallel foreach more slower that normal foreach in multicore CPU ?

2011-06-24 Thread Ali Çehreli
art(); foreach(i, ref elem; parallel(logs)) { elem = log(i + 1.0); } writeln(stopWatch.peek().msecs); } } Here is my output: CPUs : 4 8061 2686 I get similar results whether I pass 100_000 to parallel() or not. Ali

Re: Remove all elements in an associative array

2011-06-24 Thread Ali Çehreli
hould be safe: foreach (key; aa.keys) { aa.remove(key); } Ali

Re: Problem with a convoluted templated struct

2011-06-28 Thread Ali Çehreli
Node!(MyList, double, char) node2; } void main() {} But I hit other compilation problems in Algebraic, which I believe to be const-correctness issues. Also consider looking at Phobos ranges. Instead of templatizing on the container type, templatizing on the range type may be better. Ali

Obtaining aligned addresses and aligned spaces for objects

2011-06-28 Thread Ali Çehreli
sizes do include the padding bytes. The following class has the very odd size of 17! Is that by design? class C { char c; } void main() { assert(__traits(classInstanceSize, C) == 17); } Ali

Re: r/w binary

2011-06-28 Thread Ali Çehreli
y-paste mistake, right? You don't want create() before reading. You must have meant open: open( fileName ); It works with that change. > read( verStr2 ); read( ver2 ); // version > } > writeln( verStr, ver ); > } > > And this is the result: > std.stream.ReadException@std\stream.d(46): Stream is not readable > > - Joel Ali

Re: r/w binary

2011-06-29 Thread Ali Çehreli
fout.close; You are not supposed to need to close the File object yourself. Being a struct, its destructor should be called automatically. Ali

Re: Obtaining aligned addresses and aligned spaces for objects

2011-06-29 Thread Ali Çehreli
On Wed, 29 Jun 2011 10:47:39 -0400, Steven Schveighoffer wrote: > On Wed, 29 Jun 2011 01:42:37 -0400, Ali Çehreli > wrote: >> On a related note, why doesn't __traits(classInstanceSize, T) consider >> the padding bytes? If I'm not mistaken struct sizes do inclu

Re: Obtaining aligned addresses and aligned spaces for objects

2011-06-29 Thread Ali Çehreli
dn't call any destructors. > > -Steve Thank you very much for all the heads up. Luckily we don't need to deal with these issues in daily programming. Ali

Re: Get parent Tid of a thread?

2011-06-29 Thread Ali Çehreli
sTid); } void main() { writeln("owner's thisTid : ", &thisTid); Tid worker = spawn(&workerThread, thisTid); } Interestingly the two variables will have the same address but they are not equal as the assert above passes: owner's thisTid : 46B58C worker's thisTid: 46B58C Ali

Re: r/w binary

2011-06-30 Thread Ali Çehreli
ot only handy for referring to parts of other arrays, but for converting pointers into bounds-checked arrays: int* p; int[] b = p[0..8]; For strings (actually arrays), you would need .length and .ptr properties. I've never used it but you might want to consider the serialization library Orange as well: http://www.dsource.org/projects/orange Ali

Re: r/w binary

2011-06-30 Thread Ali Çehreli
ld be different if it were ubyte* or void*. Ali

Re: void.sizeof == 1, not 0

2011-07-01 Thread Ali Çehreli
ne another just by having different addresses. The following array's data will occupy 10 bytes: S[10] objects; assert(&(objects[0]) != &(objects[1])); Ali

Re: Scale advocacy

2011-07-03 Thread Ali Çehreli
std.range; // ... ElementType!Range front_or_null(Range)(Range range) { return range.empty ? null : range.front; } The template constraint has proven to be problematic though. I will open a separate thread about that. Ali

Re: Scale advocacy

2011-07-03 Thread Ali Çehreli
On Sun, 03 Jul 2011 20:07:43 +, Ali Çehreli wrote: > import std.range; > > // ... > > ElementType!Range front_or_null(Range)(Range range) { > return range.empty ? null : range.front; > } > > The template constraint has proven to be problematic though. I wi

Re: Operator Overloading and boilerplate code

2011-07-04 Thread Ali Çehreli
tring(1.5); Error: template instance S is not a template declaration, it is a struct And if I try to be smart after the error message, this seg faults the compiler: auto o = S.__ctor!string(1.5); Ali

Re: Operator Overloading and boilerplate code

2011-07-05 Thread Ali Çehreli
On Tue, 05 Jul 2011 16:20:44 +0200, Loopback wrote: > On 2011-07-05 03:11, Ali Çehreli wrote: >> struct S >> { >> this(T)(double d) >> {} >> } >> >> void main() >> { >> auto o = S(1.5); >> } >> >&

Re: Tuple [] operator

2011-08-08 Thread Ali Çehreli
hink a short vs int would make a difference when it comes to indexing (it shouldn't anyway). > > -Steve Ali

Re: Tuple [] operator

2011-08-08 Thread Ali Çehreli
On Mon, 08 Aug 2011 20:32:03 +, Ali Çehreli wrote: >> the point is, the compiler has no idea what the lvalue expression's >> type should be when you do: >> >> a[x] = 1; >> >> is it short or int? >> >> so the compiler must *know* what

Re: Modify thread-local storage from parent thread

2011-08-09 Thread Ali Çehreli
lue; } } Notes: - I had to give buffers[] to parallel() as it calls popFront() which my constant-size array can't provide. (Yes, I could have used a dynamic array.) - Note the three ref's that I used; two of those are because constant- size arrays are value types. Ali

Re: Modify thread-local storage from parent thread

2011-08-09 Thread Ali Çehreli
On Tue, 09 Aug 2011 20:37:04 +, Ali Çehreli wrote: >> I wonder if I could: >> Create a thread (task) >> Read bytes directly into the tasks' thread local storage Execute the >> thread > > I don't know what copies happen behind the scenes in the follo

Re: assertion failure in std.range.iota

2011-08-18 Thread Ali Çehreli
tion and the code above it make absolutely no sense to me. The > intention would be more clear if there was an error message, or any > documentation of the implementation, but no dice. Ali

Re: What's the technical reason that class ctors aren't virtual?

2011-08-24 Thread Ali Çehreli
I want to > add another int as a parameter), I'll have to change all the ctors in > the subclasses as well. > > Isn't that counterproductive? Sounds like it but is necessary: Which of the constructors of the derived constructors should the compiler call after calling super's matching one? If it didn't, the derived parts would be left unconstructed. Ali

Re: Why no (auto foo = bar) in while loops?

2011-08-25 Thread Ali Çehreli
;false', but // we can use c here when it evaluates to 'true'. // e.g. if it's a pointer: writeln(*c); } Ali

Re: implicit casting from primitive type

2011-08-29 Thread Ali Çehreli
} } void main() { auto some = CustomStruct(); some.attribute = [ 1, 2, 3 ]; } Ali

Re: clear bug?

2011-09-05 Thread Ali Çehreli
or clear() over the deprecated delete. delete used to destroy the object give the memory back. clear just calls the destructor. The idea is that the programmer shouldn't have much say on a new'ed object's memory. I think the thought was, if the programmers really car

Re: A small trouble with std.range.indexed

2011-09-08 Thread Ali Çehreli
/// Ditto auto ref opIndex(size_t index) { return _source[_indices[index]]; } // ... } > assert(data == [7, 0, 5, 4, 3, 2, 1, 6]); > } > > > Bye and thank you, > bearophile It's unfortunate that template the error messages cannot be more helpful. :-/ Ali

Re: Any python-like generator patterns in D?

2011-09-08 Thread Ali Çehreli
sign and even the names of range types have changed since that article has been written. These and other Phobos modules make use of ranges: http://www.d-programming-language.org/phobos/std_range.html http://www.d-programming-language.org/phobos/std_algorithm.html http://www.d-programming

Re: How to return the current object

2011-09-25 Thread Ali Çehreli
tion status of the program to the environment that started it: int main() { return 0; } Ali

Re: operator overloading and templates

2011-10-04 Thread Ali Çehreli
is useless at best, but here is a workaround: Foo opBinary(string op) (Foo rhs) if (op == "+" || op == "-") { writeln("My type: ", Foo.stringof); return Foo(); } Within the template definition, the name of the template alone means "that particular instantiation of the template". Ali

Re: object.Error: Access Violation

2011-10-04 Thread Ali Çehreli
{ > TTest test; test is null. This works: auto test = new TTest(); > test.Info!(uint)("one"); > } > > When compiling no errors. But when I try to run a program there is an > error: object.Error: Access Violation > ---- > 426348 > 4261BF > 402023 > 404C5B > 404857 > 455789 > Ali

Re: Is there a way to set an alias to specific form of a template?

2011-10-07 Thread Ali Çehreli
ias Vector!(double, 3) Vec3D; void main() { auto v2d = new Vec2D(2.2, 2.2); auto v3d = new Vec3D(3.3, 3.3, 3.3); // Alternatively, all parameters at once: auto v3d_too = new Vec3D([ 33, 33, 33, ]); } (Some would find 'size_t N' to be more appropriate since N is a dimension.) Ali

Re: Is there a way to set an alias to specific form of a template?

2011-10-08 Thread Ali Çehreli
On Sat, 08 Oct 2011 03:52:25 -0700, Roderick Gibson wrote: > On 10/7/2011 11:35 PM, Ali Çehreli wrote: >> On Fri, 07 Oct 2011 18:29:26 -0700, Roderick Gibson wrote: >> >>> This may be the completely wrong approach, but I am basically thinking >>> of something li

Re: Pointers and Ranges

2011-10-08 Thread Ali Çehreli
ange.back - myRange[i] > as well as p[1] or Only with RandomAccessRanges. > p[-1] with ranges. That should be considered out of bounds with ranges, but it is possible to achieve with opIndex() for RandomAccessRanges. Ali P.S. I am in the process of translating my Turkish D book to Engli

  1   2   3   4   5   6   7   8   9   10   >