Re: Detecting inadvertent use of integer division

2009-12-14 Thread Saaa
Don wrote Consider this notorious piece of code: assert(x1); double y = 1 / x; This calculates y as the reciprocal of x, if x is a floating-point number. But if x is an integer, an integer division is performed instead of a floating-point one, and y will be 0. It's a very common newbie

Re: out of memory error with template mixins

2009-12-03 Thread Saaa
Removing a struct definition from the second mixin seems to fix the problem. Is this a (known) bug? The struct was only used within that template. public struct S { enum LOCAL { ONE, TWO }; LOCAL local; bool b = false; StructOut s; ENUM_OUT eo; }

Re: out of memory error with template mixins

2009-12-03 Thread Saaa
bearophile wrote: Saaa: Is this a (known) bug? It's generally better if you show a tiny compilable example that has the problem. Bye, bearophile I'm trying :) I just hoped somebody would recognize it from my babbling

Re: out of memory error with template mixins

2009-12-03 Thread Saaa
Tomorrow I'll continue my quest for the mall piece of code which will choke the compiler.

Re: out of memory error with template mixins

2009-12-03 Thread Saaa
Can't recreate the error in a small test project (5 modules). I think the problem lies somewhere in between cyclic module imports, mixin struct definitions and maybe the actual size of the class(1k) and its complexity of interfaces(8). One more thing: The out of memory is before it can tell

out of memory error with template mixins

2009-12-02 Thread Saaa
I was trying out composite oriented programming, meaning moving class functionality into templates which you then mixin. First part mixined just fine, second also ok, third . . - Error : Out of memory (2GB VM) Even with an empty template :(

why can't structs implement interfaces?

2009-11-24 Thread Saaa
struct S : Pos {} Why is this not possible?

Re: why can't structs implement interfaces?

2009-11-24 Thread Saaa
bearophile wrote: Moritz Warning: If you only what a contract that certain functions are implemented, then it just need to be implemented in the compiler frontend. In the meantime this can be done with a template mixin, where the template statically asserts the presence of the

Re: why can't structs implement interfaces?

2009-11-24 Thread Saaa
Bill Baxter wrote: On Tue, Nov 24, 2009 at 2:49 PM, Saaa em...@needmail.com wrote: bearophile wrote: Moritz Warning: If you only what a contract that certain functions are implemented, then it just need to be implemented in the compiler frontend. In the meantime this can be done

Re: why can't structs implement interfaces?

2009-11-24 Thread Saaa
Bill Baxter wrote: daniel.keep.li...@gmail.com wrote: (This is all off the top of my head.) nice explanation snipped -- thanks snipped --bb Thanks for all the explanations!

Per object static array sizing

2009-11-20 Thread Saaa
Is it possible to have different objects of the same class have (refs to) different sized static arrays? I loop through the 2D arrays diagonally and as far as I understand arrays, dynamic ones don't really like this. Thanks!

Re: Per object static array sizing

2009-11-20 Thread Saaa
Also random accessing the array :)

Re: Arrays passed by almost reference?

2009-11-05 Thread Saaa
Ali Cehreli wrote... This helps me with the meaning of in, out ref. http://bayimg.com/NaeOgaaCC

Re: The Thermopylae excerpt of TDPL available online

2009-10-31 Thread Saaa
Andrei Alexandrescu wrote Saaa wrote: Andrei Alexandrescu wrote: Andrei Alexandrescu wrote: Saaa wrote: Could anybody clear these up for me? p16. Is there anything other than the random values, unsafe about void assignment? I'd put your feedback on my pile of things to do, but now

Re: The Thermopylae excerpt of TDPL available online

2009-10-31 Thread Saaa
Andrei Alexandrescu wrote Saaa wrote: Andrei Alexandrescu wrote: Andrei Alexandrescu wrote: Saaa wrote: Could anybody clear these up for me? p16. Is there anything other than the random values, unsafe about void assignment? I'd put your feedback on my pile of things to do, but now

Re: The Thermopylae excerpt of TDPL available online

2009-10-30 Thread Saaa
Could anybody clear these up for me? p16. Is there anything other than the random values, unsafe about void assignment? p18. What is unsafe about implicit conversion of static to dynamic array? Meaning getting a dynamic array pointing to a stack allocated array. Any

Re: The Thermopylae excerpt of TDPL available online

2009-10-30 Thread Saaa
Andrei Alexandrescu wrote: Andrei Alexandrescu wrote: Saaa wrote: Could anybody clear these up for me? p16. Is there anything other than the random values, unsafe about void assignment? I'd put your feedback on my pile of things to do, but now that you ask, I made this change

Re: The Thermopylae excerpt of TDPL available online

2009-10-29 Thread Saaa
Also, no mention about .dup not being a deep dup.

Re: The Thermopylae excerpt of TDPL available online

2009-10-29 Thread Saaa
crp p20. 40 words? those where for myself, to check

Re: The Thermopylae excerpt of TDPL available online

2009-10-29 Thread Saaa
Andrei Alexandrescu wrote It's a rough rough draft, but one for the full chapter on arrays, associative arrays, and strings. http://erdani.com/d/thermopylae.pdf Any feedback is welcome. Thanks! Andrei Makes me want to read the rest! Will we get the electronic version with the paper

Re: The Thermopylae excerpt of TDPL available online

2009-10-29 Thread Saaa
Also, no mention about .dup not being a deep dup.

Re: The Thermopylae excerpt of TDPL available online

2009-10-29 Thread Saaa
Saaa wrote Also, no mention about .dup not being a deep dup. Sorry, should've been attached to my response

Re: The Thermopylae excerpt of TDPL available online

2009-10-29 Thread Saaa
crp p20. 40 words? those where for myself, to check

Re: AA.remove in foreach AA = new vs cleaning

2009-10-22 Thread Saaa
Saaa wrote: Steven Schveighoffer wrote But I've changed everything to `new` the array afterwards as I deleted all the keys anyways. Not sure what you mean here. foreach (K k, ; aa) { .. //aa.remove(k); } aa = new int[char]; Error: new can only create structs, dynamic arrays

Re: Automatic getter/setter generation

2009-10-22 Thread Saaa
Lutger wrote: I'm not sure it is very useful. I can think of a couple of reasons to define simple getter / setters: - must be done when implementing an interface - binary compatibility perhaps (again: interfaces) - you will or might add functionality to the get/set functions at a later

Re: AA.remove in foreach AA = new vs cleaning

2009-10-21 Thread Saaa
Steven Schveighoffer wrote: Yes, behavior is undefined. from http://digitalmars.com/d/2.0/statement.html#ForeachStatement : The aggregate must be loop invariant, meaning that elements to the aggregate cannot be added or removed from it in the [loop body] I suspect removing the current key

Re: Sorry, I just love templates, AAs and mixins :)

2009-10-18 Thread Saaa
Ellery Newcomer wrote: grauzone wrote: Saaa wrote: public void addToAA(char[] var_name, KT, ET)(KT key, ET element) { mixin(ET.stringof~`[]* elements = key in `~var_name~`;`); if( elements == null ) { ET[] temp; temp.length = 1; temp[0] = element; mixin(var_name

Re: Sorry, I just love templates, AAs and mixins :)

2009-10-18 Thread Saaa
Ary Borenszweig wrote: Saaa wrote: public void addToAA(char[] var_name, KT, ET)(KT key, ET element) { mixin(ET.stringof~`[]* elements = key in `~var_name~`;`); if( elements == null ) { ET[] temp; temp.length = 1; temp[0] = element; mixin(var_name~`[key] = temp

Sorry, I just love templates, AAs and mixins :)

2009-10-16 Thread Saaa
public void addToAA(char[] var_name, KT, ET)(KT key, ET element) { mixin(ET.stringof~`[]* elements = key in `~var_name~`;`); if( elements == null ) { ET[] temp; temp.length = 1; temp[0] = element; mixin(var_name~`[key] = temp;`); } else { (*elements).length =

Re: Goodbye

2009-10-14 Thread Saaa
Chris Nicholson-Sauls wrote The most important thing is remembering that black text on a white screen carries absolutely no emotional information whatsoever, in either direction, in any case. The exception that proves the rule, of course, is ZOMG NERD RAGE ALLCAPS. Otherwise, there's

Re: New XML parser written for D1 and D2.

2009-10-14 Thread Saaa
Michael Rynn wrote I have made a validating or optionally none validating XML parser in D. nice But I would like to have it made available so others can test. Maybe add it as an enhancement in bugzilla Where and to whom can I post the 56 KB source code zip? NG attachement? Or is that

Re: New XML parser written for D1 and D2.

2009-10-14 Thread Saaa
Justin Johansson wrote Saaa Wrote: Michael Rynn wrote I have made a validating or optionally none validating XML parser in D. nice But I would like to have it made available so others can test. Maybe add it as an enhancement in bugzilla Where and to whom can I post the 56 KB

Re: New XML parser written for D1 and D2.

2009-10-14 Thread Saaa
Michael Rynn wrote Where and to whom can I post the 56 KB source code zip? Attaching it to an enhancement in bugzilla would be best, I think.

Re: Goodbye

2009-10-13 Thread Saaa
Yigal Chripun wrote ego has nothing to do with being smart. you can be extremely smart without getting on people's nerves all the time. A smart person can choose when to get on somebody's nerves ;)

Re: Goodbye

2009-10-13 Thread Saaa
Yigal Chripun yigal...@gmail.com wrote in message news:hb2u2n$2if...@digitalmars.com... On 13/10/2009 20:24, Saaa wrote: Yigal Chripun wrote ego has nothing to do with being smart. you can be extremely smart without getting on people's nerves all the time. A smart person can choose when

Re: another d demoscene entry

2009-10-11 Thread Saaa
#ponce wrote... Hi, We won another demo compo with a D entry (at MAIN demoparty) http://www.pouet.net/prod.php?which=53942 We tried to make a bigger and more impressive entry this time. Note that it's a french party so it's not Breakpoint. D clearly allowed us to be more productive

Re: Use of first person in a book

2009-10-08 Thread Saaa
Jarrett Billingsley wrote On Thu, Oct 8, 2009 at 12:04 AM, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: I'd decided to not use the first person at all in TDPL, but now I find myself a bit constrained by that decision. I personally think a small amount of meta-references and

Re: implicit ubyte casting

2009-10-01 Thread Saaa
Jeremie Pelletier wrote Then why use an ubyte instead of a byte or an int? I wasn't me who wrote that part of the code :) You could also just do: for(int i = cast(byte)nloop; i 10; i++) I forgot the minus sign: for(int i = -cast(int)nloop;i 10; i++) Still think it is unnecessary bug-prone.

Re: implicit ubyte casting

2009-10-01 Thread Saaa
Moritz Warning wrote This is a troublesome behavior: ubyte z = 5; int x = -z; // x now is 251 int y = -1 * z; // y is now -5 Yes, troublesome is the correct word :) Does anybody ever use the =-z behaviour?

Re: Null references redux + Cyclone

2009-09-30 Thread Saaa
Andrei Alexandrescu wrote I wonder whether this would be a good topic for TDPL. Currently I'm thinking it's too low-level. I do plan to insert a short section about implementation, just not go deep inside the object model. Andrei I'd really love to see more about implementations as it

Re: looking for an IDE

2009-09-30 Thread Saaa
Phil Deets wrote I tried Descent, but it didn't work well at all with my D2 program. It also didn't support building. I'll look into Poseidon. Thanks. What exactly do you expect from supporting building? I use descent to build my project by using the external tool setup shown here:

Re: ref arguments

2009-09-29 Thread Saaa
Jeremie Pelletier wrote ... Wow, talk about slow.. thanks again for all the help/explanations ! http://bayimg.com/NaeOgaaCC I tried callee/caller but it is just that bit more difficult to distinguish. There should be more diagrams like this.. would make a lot of things a lot easier (to me at

Re: ref arguments

2009-09-21 Thread Saaa
Steven Schveighoffer wrote: On Mon, 21 Sep 2009 11:12:49 -0400, #ponce alil...@gmail.com wrote: Is there a reason to use ref instead of in, inout or out ? I'm using D1 and it's not in the spec. It is here in the spec: Function Parameters http://www.digitalmars.com/d/1.0/function.html ref

Re: better than union and array questions

2009-09-21 Thread Saaa
Don wrote: You always seem to be so negative! In one recent DMD release, half the changes were bugfixes requested by you... If everyone involved in compiler development spent 100% of their time on bearophile requests, you still might not get everything you want g. Actually you have at

Re: better than union and array questions

2009-09-19 Thread Saaa
bearophile Wrote: Saaa: Is there a better way to support arrays of any type? Currently all the code working with these Structs are templated with loads of static ifs in them. You have to ask a more precise question if you want an answer. Maybe a more general one :) I use a tagged

Re: std.bitarray

2009-09-18 Thread Saaa
Ah, slicing, of course, thanks! Hello Saaa, I understand a bitarray being faster than a boolean array as the first uses bitwise (hardware) operators. Is this a correct understanding of the situation? Why then is a boolean array not implemented in that way? Because you can't slice a bit

better than union and array questions

2009-09-18 Thread Saaa
(D1 Phobos) I use the struct below like: Struct[][char[]] _struct; Is there a better way to support arrays of any type? Currently all the code working with these Structs are templated with loads of static ifs in them. Also, is it possible to add a .deepdup property to all arrays? One last

Re: better than union and array questions

2009-09-18 Thread Saaa
(D1 Phobos) I use the struct below like: Struct[][char[]] _struct; Is there a better way to support arrays of any type? Currently all the code working with these Structs are templated with loads of static ifs in them. Also, is it possible to add a .deepdup property to all arrays? One

std.bitarray

2009-09-17 Thread Saaa
I understand a bitarray being faster than a boolean array as the first uses bitwise (hardware) operators. Is this a correct understanding of the situation? Why then is a boolean array not implemented in that way? I expect there to be a good reason which I just don't know. I'd like to be able to

Re: DData

2009-09-12 Thread Saaa
How should I procede to get this functionallity into phobos?

Re: delegate reference

2009-09-09 Thread Saaa
Daniel Keep daniel.keep.li...@gmail.com wrote in message news:h88cck$1or...@digitalmars.com... Saaa wrote: abstract class C { int method(); } class C2:C { int method() return 2; } class C3:C { int method() return 3; } int delegate() deleg; void main() { C c; C2 c2 = new

Re: delegate reference

2009-09-09 Thread Saaa
Ary Borenszweig a...@esperanto.org.ar wrote in message news:h88i6o$23h...@digitalmars.com... Saaa wrote: Daniel Keep daniel.keep.li...@gmail.com wrote in message news:h88cck$1or...@digitalmars.com... Saaa wrote: abstract class C { int method(); } class C2:C { int method() return 2

Re: delegate reference

2009-09-09 Thread Saaa
class Foo { C* c; this(ref C c) { this.c = c; } int invoke() { return (*c).method(); } } void main() { // ... deleg = (new Foo(c)).invoke; } Or something similar. This is dangerous. Do not allow either the Foo instance or the delegate to survive past the

Re: delegate reference

2009-09-09 Thread Saaa
Hello Saaa, How should I do this then? C c; C2 c2 = new C2; C3 c3 = new C3; c=c2; auto dg = { return c.method(); }; c=c3; I actually did it like this before :) Thanks But like this I need to do the c is null checking within the function literal. I'm not sure how these function

Re: delegate reference

2009-09-09 Thread Saaa
Or does the compiler handle them like any other function and just thinks of a name itself ? Exactly. If you compile with DMD and the -v flag you can see what names it gives them. :) nice Thanks!

Re: delegate !is null

2009-09-08 Thread Saaa
Steven Schveighoffer schvei...@yahoo.com wrote in message news:op.uzxs4wyreav...@localhost.localdomain... On Sun, 06 Sep 2009 18:54:47 -0400, Saaa em...@needmail.com wrote: I'd like to set D's delegate to a method which is not yet available (like c.method). I solved this by encapsulating

Re: delegate !is null

2009-09-08 Thread Saaa
The problem lies more in that I'd like to point to something which is not there yet. In the code 'c.method()' is not there yet, as c is null. Maybe I should create a dummy object for c to point to in stead of null ? That way I point the delegate to the dummy method and ignore it as long as

Re: delegate !is null

2009-09-08 Thread Saaa
Hm... I'm still confused. Why not just set the delegate to null? Why do you need to have the delegate set to something? It is for the gui. I give it a list of things to display. And some of these things don't yet exist or can be deleted at any time. I'd like it to display the last valid

Re: Special Token __FUNCTION__

2009-09-07 Thread Saaa
But most of the ideas I suggest here get dispersed like tears in rain :-) I read them ;-)

Re: delegate !is null

2009-09-06 Thread Saaa
Steven Schveighoffer schvei...@yahoo.com wrote in message news:op.uzqxxo1neav...@localhost.localdomain... On Fri, 04 Sep 2009 14:33:12 -0400, Saaa em...@needmail.com wrote: class C { private int i; int method() { return i; } } class D { private int delegate(void

delegate !is null

2009-09-04 Thread Saaa
class C { private int i; int method() { return i; } } class D { private int delegate(void) _deleg; this(int delegate(void) d) { _deleg = d; } void write() { if(_deleg !is null) } writef(_deleg()); } } } C c = null; D d = new d;

Re: Unofficial wish list status.(Sep 2009)

2009-09-01 Thread Saaa
Only curious, what is the influence record of the wishlist?

Re: CRTP in D?

2009-08-19 Thread Saaa
Mixins can be used to do a lot (most? all?) of things CRTP is used for: class Class(alias MixMe) { mixin MixMe impl; ... void doSomething { impl.doIt(); } } where can I read about class parameters?

RegExp.match question

2009-08-17 Thread Saaa
const char[] re1 = `(re)1`; const char[] re2 = `(re)2`; char[] matchWrite(RegExp re) { writefln(re.match(1),`,`,re.match(2)); return ; } std.regexp.sub(`re1 re2`, re1~'|'~re2, matchWrite, g); --- prints re, re,re // shouldn't this be `,re`?

Re: std2.xml and std2.encoding for D 1.0 available at D source

2009-08-12 Thread Saaa
I cannot believe that anybody actually uses the std2 project files. Why do you believe this? I do.. Ran unit tests and also successfully rab the books.xml example. Ok, so I can use this one as well, thanks! Re-enabled the disabled unittest in std.encoding, and fixed the little bug that was

Re: ignored phobos request

2009-08-12 Thread Saaa
Lars T. Kyllingstad pub...@kyllingen.nospamnet wrote in message news:h5tsuu$bc...@digitalmars.com... Saaa wrote: Some time ago I requested something on .D, but it was ignored. I'm interested in why this is so. It was only a small request, maybe not fitting for .D but dsourse/phobos said

Re: ignored phobos request

2009-08-12 Thread Saaa
filed http://d.puremagic.com/issues/show_bug.cgi?id=3248

ignored phobos request

2009-08-11 Thread Saaa
Some time ago I requested something on .D, but it was ignored. I'm interested in why this is so. It was only a small request, maybe not fitting for .D but dsourse/phobos said that was the place for such things. (Maybe it was unintelligible again?) --- Could an option be added to the formatting

Re: Descent, now with Open Type Hierarchy

2009-07-29 Thread Saaa
2 is very nice towards the namespace how will you do regex.find vs string.find? Ary Borenszweig a...@esperanto.org.ar wrote in message news:h4pcpc$2ef...@digitalmars.com... Qian Xu escribió: Ary Borenszweig wrote: Enjoy :-) Great work. BTW: Is there any plan to make a Organize Imports

Re: Descent, now with Open Type Hierarchy

2009-07-29 Thread Saaa
2 is very nice towards the namespace how will you do regex.find vs string.find? Just what JDT does: show you the matches of find and allow you to choose one of them. never used JDT for anything but your descent :) but I should have known this is handled nicely already

Re: std.format request

2009-07-29 Thread Saaa
I don't see how all this property talk has anything to do with formatting! :D

Re: D Framework

2009-07-29 Thread Saaa
Marketing? I don't think Walter's really looking to get rich with D. I vaguely remember Walter asking for ideas to make money with D though. (might remember that incorrectly:) And there are plenty of popular things out there with silly-sounding names - Hadoop, Twitter, Meebo, Mibbit..Google

std.format request

2009-07-28 Thread Saaa
Could an option be added to the formatting to elide trailing zero's for %f ? That way it is possible to create an more optimal formatting for which the following holds: float f; s = format(f); float f2 = to!(float)(s); assert(f==f2); The formatting I'm trying to get can be seen here (decimal):

Re: aa bug?

2009-07-28 Thread Saaa
But you never inserted anything in aa[test]. You must do: S s; aa[test] = s; aa[test].i = 10; or: S s; s.i = 10; aa[test] = s; erm, ok Thanks So no creation on use :) Personally I find the declation step clutter in the first case. Maybe promote the bug to a request?

Re: aa bug?

2009-07-28 Thread Saaa
struct literals .. need to remember all D's features :) D1.046 seems SS aa[test]=S(); works fine as well Try: struct S { int i; } S[char[]] aa; void main() { aa[test] = S(10); } In theory a Sufficiently Smart Compiler is able to optimize that code well. Bye, bearophile

Re: My own IDE for D

2009-07-27 Thread Saaa
Your Idea isn't so bad, but why should a programmer translate his complete project into another language? I mean, when I've chosen Java, then I want to make Java:) and NOT D or C#... D1 to D2 I can fathom

precision test results

2009-07-26 Thread Saaa
Maybe interesting for other people Abstract: %.8e format holds full precision information for floats making it a good %a contender float have max 24bit precision 2^-24 = 0.00059604644775390625 2^-23 = 0.0011920928955078125 to distinguish between these two you only need a precision of 8.

Re: What makes D, D?

2009-07-24 Thread Saaa
That is a question for a philosopher, right up there with what makes you, you? IIRC the body replaces 100% of it's matter several times of your life. Some parts more often than others. No, some parts stay with you for the rest of your life (e.g. nuclear pore scaffold in brain cells) What

Re: What makes D, D?

2009-07-24 Thread Saaa
I suppose the answer would be the same, too: The Soul. Lol

formatting precision

2009-07-24 Thread Saaa
Isn't the precision of a float 8 decimal digits? .dig reports 6 Why isn't %.100g cropped to the max decimal digits of the accompanying type? floating point types are printed with 20 digits.

Re: formatting precision

2009-07-24 Thread Saaa
I just want to format in full precision. As far as I can see 6 digits is not the full precision e.g. 0x7EAB = 1.1342746e38

Re: formatting floating point

2009-07-13 Thread Saaa
You'd just have to convert each element of the array separately. I found the formatting options, they are in std.format.. (I was apparently searching for the 'g' option.. ) this seems to work (using std2.string.format) double[] d1; d1=[double.max,double.min]; char[] c; c=format(

Re: formatting floating point

2009-07-11 Thread Saaa
double d[2] = [ 0, 1, double.max]; char[] c = format(d); How do I get c to represent full precision? [0,1,1.7976931348623157e+308] // but then with double.max being represented fully You want a 309-digit number consisting mostly of 0s? Yes, but only if they are necessary. 0 doesn't need

pass variable names

2009-07-09 Thread Saaa
Is it possible to get the passed variable name à la: -- void functio(A...)(ref A a) { writefln(typeof(a[0])); } int i; functio(i); // prints i -- Also how do I fix this: -- functio(`i`); // Error: i is not an lvalue --

Re: pass variable names

2009-07-09 Thread Saaa
No. You should be able to get the name using an alias: void func(alias var)() { writefln(var.stringof); } Can this be combined with the tuple parameter? But you can't do it at runtime. Also how do I fix this: -- functio(`i`); // Error: i is not an lvalue You have to store the

Re: parsing again

2009-07-02 Thread Saaa
Kisses Ary: It seems you can't mixin cases separately, you need to mixin the whole switch (bug?) string CasesString(int depth) { string res; res ~= `switch( depth ){`; for (int i = 0; i depth; ++i) { res ~= `case `~ctToString(i)~`:`~ ` if( temp`~ indexString(i) ~`.length

parsing again

2009-06-30 Thread Saaa
Is it possible to do a call like -- arrayLength!(T[])( temp, index[0..depth] ); //temp is (multi)array being created while parsing an (multi)array in a file //index[] is an array of the current index //depth = current depth -- in stead of -- switch( depth ) { case 0: if( temp.length

array walker

2009-06-30 Thread Saaa
I am currently approaching arrays in a absolute manner, like for setting a value: --- private template indexAssign(T: T[]) { void indexAssign(ref T array, BaseType!(T) value, int[] indices) { static if( is( typeof(array[0]) == typeof(value))) { array[indices[0]] = value; }

Re: Compiling Templates

2009-06-29 Thread Saaa
Always nice to see the inner workings, thanks. Here a few things that bugged me: Seeing templates as runtime functions, making the whole instantiation thing kind of strange :) Trying to use implicitly deduces parameters for function templates. Writing Foo(d) iso Foo!(int [][])(d). -- template

Re: Should be easy

2009-06-16 Thread Saaa
template BaseType(T: T[]) { alias BaseType!(T) BaseType; } template BaseType(T) { alias T BaseType; } Otherwise, you need indexAssign: void indexAssign(TArray : TArray[])(TArray array, BaseType!(TArray) value, int[] indices...) { static if (is (typeof (array[0]) == typeof(value)) {

Re: Should be easy

2009-06-15 Thread Saaa
Ever heard of recursion? Why don't you simply handle all types recursively? I'm still very interested in what exactly that means. Could you maybe give a small example? int Index(T)(T arr, int[] ind) { static if(is(T B == B[][])) // if array of array return

Re: A public apology.

2009-06-15 Thread Saaa
So have I. But we can at least still shout. Please do

Re: A public apology.

2009-06-15 Thread Saaa
Jarrett Billingsley jarrett.billings...@gmail.com wrote in message news:mailman.272.1245123167.13405.digitalmars-d-le...@puremagic.com... On Mon, Jun 15, 2009 at 11:26 PM, downsdefault_357-l...@yahoo.de wrote: Jarrett Billingsley wrote: On Mon, Jun 15, 2009 at 10:15 PM, Derek

Should be easy

2009-06-12 Thread Saaa
I can't figure out how to create the IndexArray function, it should work on arrays of any depth int[][][] array; //any depth array.length=10; array[1].length=3; array[1][2].length=4; array[1][2][1]=99; writefln(array); //[[],[[],[],[0,99,0,0]],[],[],[],[],[],[],[],[]] int[3] index; //same

Re: Should be easy

2009-06-12 Thread Saaa
Thanks. But my problem lays in supporting arrays of arbitrary depth. For 2 dim array I like auto a=new char[][](40,25); so that a[39][24]='B'; 'B' is at the bottom right of the 2D array.

Re: Should be easy

2009-06-12 Thread Saaa
IndexArray should take an array of integers as well. The int[] foo... syntax is implicit convert to array anyway. I think I'll go with Christophers code, hope you don't mind :) Also, please bottom-post. It's the convention. :) Why is that? scroll scroll I probably use a retarded

Re: Should be easy

2009-06-12 Thread Saaa
Saaa wrote: I can't figure out how to create the IndexArray function, it should work on arrays of any depth BaseType!(TArray) index(TArray : TArray[])(TArray array, int[] indices...) { return index(array[indices[0]], indices[1..$]); } TElement index(TElement)(TElement element, int

Re: [OT] quoting text

2009-06-12 Thread Saaa
I guess it depends on your style. If you respond to the entire message, then putting at the top makes sense, because then you can read the response quickly, and read the history below if you want. I also switch my way of reply on the type of the reply and often find it strange people quote

array depth template

2009-06-11 Thread Saaa
Is this a good way to get the depth of an array? int getArrayDepth(T)(ref T array) { static if( is(T A:A[]) ) { A arr; return 1 + getArrayDepth(arr); } else { return 0; } return -1; }

Re: array depth template

2009-06-11 Thread Saaa
Any advantage to using two? I just tend to prefer template specialization when doing type pattern matching. It works out better than is() in some cases. Looks very Haskell like :) He also does : is( T B ==B[]) iso is( T B:B[] ) Any significant difference there? I'm.. not sure, in this

  1   2   3   >