Re: dmd 1.068 and 2.053 release

2011-05-16 Thread Don
Jonathan M Davis wrote: On 2011-05-15 03:50, Joel Christensen wrote: Looks like enum's are tighter (eg. 'enum last = media[ $ - 1 ];' doesn't work now). It was working in 52. I had heard it might be relaxed, not tightened. I get the error, 'cannot be read at compile time'. Also immutable imstr

Re: dmd 1.068 and 2.053 release

2011-05-16 Thread Jonathan Crapuchettes
I'm getting a segfault while compiling my code with the 64-bit version of dmd 2.053. I can't seem to figure out where the problem exists, but something is making me think that it is a problem with std.parallelism. Attached is the output of dmd with -v. Walter Bright wrote: Thanks for

Re: dmd 1.068 and 2.053 release

2011-05-16 Thread Walter Bright
On 5/16/2011 10:11 AM, Jonathan Crapuchettes wrote: I'm getting a segfault while compiling my code with the 64-bit version of dmd 2.053. I can't seem to figure out where the problem exists, but something is making me think that it is a problem with std.parallelism. Attached is the output of dmd

Re: Patterns of Human Error - my presentation at the DC ACM

2011-05-16 Thread Caligo
Have you ever placed a 9-volt battery on your tongue? It's not very pleasant, specially when someone asks you to do it and you don't know what's coming. On a serious note, the topic reminds me of an interesting book that I read; The Design of Everyday Things by Donald Norman, is one of the

Re: ld issues again

2011-05-16 Thread Daniel Gibson
Am 16.05.2011 07:39, schrieb Brian Myers: Hello all, Thanx for the assistance rendered before. I've removed all my previous installation attempt and installed D 2.0 under Ubuntu with the one click installer. Now when compiling I get the following, which is different from what I was

Re: Flagshit concurrency

2011-05-16 Thread Nick_B
On 16/05/2011 5:49 a.m., Robert Clipsham wrote: On 15/05/2011 10:08, Gilbert Dawson wrote: Hello I'm new to D. Welcome :) I've been studying new languages for new concurrency ideas. I'd like to implement a small and lightweight Lighttpd replacement and replace the scripting with MiniD. One

Re: reddit discussion about Go turns to D again

2011-05-16 Thread bearophile
Alex_Dovhal: Daniel proposal IMHO looks good, p_map, pMap?? pmap sounds good :-) Bye, bearophile

Re: Multi typed value return.

2011-05-16 Thread Matthew Ong
On 5/13/2011 12:47 AM, bearophile wrote: Matthew Ong: Any plan to support this really cool feature of Multiple type return value? Multiple return values is a very handy feature, I use it quite often in Python. It makes the code more natural and readable, and avoids some troubles given by out

Re: Making D Lang More easy.

2011-05-16 Thread Matthew Ong
On 5/12/2011 11:17 PM, Jonathan M Davis wrote: On 2011-05-12 04:01, Matthew Ong wrote: Hi Mafi, Thanks very much for the response in earlier post about the solid class. just FYI: import java.util.ArrayList; // can be written as import std.container : SList; The syntax is valid for importing

Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Mehrdad
Hi! I posted this question on StackOverflow about D: http://stackoverflow.com/questions/6015008/how-to-delete-an-element- from-an-array-in-d and the answers are quite surprising to me. Are arrays really supposed to be substitutes for array lists if we can't remove anything from them? It seems

Re: Making D Lang More easy.

2011-05-16 Thread Matthew Ong
On 5/14/2011 5:52 AM, Andrej Mitrovic wrote: And here is how I use uncrustify via a batch file: D:/Apps/UniversalIndentGUI_win32/indenters/uncrustify.exe --no-backup --replace %1 -c D:/Apps/UniversalIndentGUI_win32/indenters/uncrustify.cfg %1 is the filename, e.g. C:/main.d, --no-backup means

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Daniel Gibson
Am 16.05.2011 11:54, schrieb Mehrdad: Hi! I posted this question on StackOverflow about D: http://stackoverflow.com/questions/6015008/how-to-delete-an-element- from-an-array-in-d and the answers are quite surprising to me. Are arrays really supposed to be substitutes for array lists

Re: Making D Lang More easy.

2011-05-16 Thread Matthew Ong
On 5/12/2011 2:23 AM, Walter Bright wrote: Hi Walter, Not sure what you mean by more complex than Java. The order of imports in D is not important. Hmm... Someone more experience in Java and also D might want to update this URL and help some new Java To D developer to figure out the import

Re: reddit discussion about Go turns to D again

2011-05-16 Thread Kagamin
Walter Bright Wrote: On 5/15/2011 5:22 PM, Andrei Alexandrescu wrote: On 05/15/2011 06:39 PM, Walter Bright wrote: Making up unique names is the right thing to do for branding and establishing a trademark. Otherwise, search engine friendly terms are far and away the better option. That

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Vladimir Panteleev
On Mon, 16 May 2011 12:54:33 +0300, Mehrdad wfunct...@hotmail.com wrote: Hi! I posted this question on StackOverflow about D: http://stackoverflow.com/questions/6015008/how-to-delete-an-element- from-an-array-in-d and the answers are quite surprising to me. I've updated my answer. Sorry my

Re: Making D Lang More easy.

2011-05-16 Thread bearophile
Matthew Ong: // the line below is really dangerous and might have been missed out because it is NOT flagged. Such things are always flag within Java and also google Go and maybe c/c++. Hopefully this will be flag as compilation erro to others kind of syntax. foo(); // C.foo() is

Re: Comparing double and float values

2011-05-16 Thread Matthew Ong
On 5/13/2011 3:12 PM, Don wrote: std.math.isIdentical(). I doubt it would ever be appropriate to use this in a financial context, it's more for precise testing of math functions. Note that, for example, isIdentical(-0.0, +0.0) returns false. Hi, Hmm.. That is main reason that I can see that

Re: reddit discussion about Go turns to D again

2011-05-16 Thread Matthew Ong
On 5/15/2011 5:56 PM, Timon Gehr wrote: You are to a certain extent right, but Go is appealing in a few ways. Many Go users are coming from C or scripting languages, so Go is an evolution for them, even if the language is a downgrade from major programming language features. Then many of the

Re: Implementing std.log

2011-05-16 Thread Jonas Drewsen
On 14/05/11 19.04, Andrei Alexandrescu wrote: On 5/9/11 1:52 AM, Andrei Alexandrescu wrote: [snip] I updated my std.log draft. Added a lot of features including formatted writing, delayed logging, and a variety of configuration options. Replaced the redundant log.xyz with logXyz. The

Re: struct destructors

2011-05-16 Thread Steven Schveighoffer
On Mon, 09 May 2011 17:04:49 -0400, Sean Kelly s...@invisibleduck.org wrote: On May 9, 2011, at 12:51 PM, Alexander wrote: On 09.05.2011 19:38, Sean Kelly wrote: Not currently. I thought I wrote some explanation of why... OK, thanks - I've read the ticket. Though, the problem can be

Re: AA Troubles

2011-05-16 Thread Steven Schveighoffer
On Tue, 10 May 2011 21:54:30 -0400, Jonathan Crapuchettes jcrapuchet...@gmail.com wrote: Hey all, I have been working with a lot of associative arrays of late and been running into some problems with the built-in implementation. It appears that very heavy use in an application can cause

Re: reddit discussion about Go turns to D again

2011-05-16 Thread Matthew Ong
Hi, Oh a few more thing that got my interest is how the Go model their data. Not entirely like how other conventional OO does it. They do NOT have Object inheritance. But uses interface to some how 'bypass' that. http://golang.org/doc/effective_go.html Conversions ... // this function is now

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Andrei Alexandrescu
On 05/16/2011 04:54 AM, Mehrdad wrote: Hi! I posted this question on StackOverflow about D: http://stackoverflow.com/questions/6015008/how-to-delete-an-element- from-an-array-in-d and the answers are quite surprising to me. Are arrays really supposed to be substitutes for array lists if we

Re: reddit discussion about Go turns to D again

2011-05-16 Thread Matthew Ong
Hi Walter, alias is indeed a very very useful feature in D. It make string easy and well define. Just need some Auto Documentation search-able tool for new developer to help them find. As for now, I am using grepwin to help figure things out. Matthew Ong

Re: Builtin regex (Was: How to complex switch?)

2011-05-16 Thread Matthew Ong
Hi, Seems like some people also had the same idea about D supporting more complex switch syntax and given more interesting reasons. Perhaps can be consider for D 3.0 or ... I am new here, please understand, but wish to see D take off because I do see some nice syntax in D.

Re: reddit discussion about Go turns to D again

2011-05-16 Thread Mike Parker
On 5/16/2011 12:06 PM, Andrei Alexandrescu wrote: On 05/15/2011 10:04 PM, Daniel Gibson wrote: So you have to write std.parallel_algorithm.map() instead of map() all the time? alias std.parallel_algorithm p; Andrei Or this, which I prefer to alias: import p = std.parallel_algorithm;

Re: Flagshit concurrency

2011-05-16 Thread Jonas Drewsen
On 15/05/11 19.49, Robert Clipsham wrote: On 15/05/2011 10:08, Gilbert Dawson wrote: Hello I'm new to D. Welcome :) I've been studying new languages for new concurrency ideas. I'd like to implement a small and lightweight Lighttpd replacement and replace the scripting with MiniD. One has

Some features should NOT include from GO/Java.

2011-05-16 Thread Matthew Ong
Hi All, The reason I am starting this thread is to gather some valid/experience that people do not like about using Go or even Java. Naturally D-programming might not wants to repeat the same error. Java: 1) Swing API --- The inheritance tree is too deep. New OO encourages flatten object (1-2

Re: Making D Lang More easy.

2011-05-16 Thread Matthew Ong
On 5/12/2011 7:19 PM, Russel Winder wrote: Hi Russel, I looked into this URL, http://www.russel.org.uk/Bazaar/ I put my little experimental codes in microbenchmarking in Bazaar branches accessible on my web site. Note this is microbenchmarking with all the hassles that go with it. Especially

Re: reddit discussion about Go turns to D again

2011-05-16 Thread Sean Kelly
std.paralellogrithm ;-) Sent from my iPhone On May 15, 2011, at 8:01 AM, bearophile bearophileh...@lycos.com wrote: Andrei: (That's also why we should think of a shorter name instead of parallel_algorithm... The idea of adding parallel algorithms to Phobos is good, people may use them

Re: Making D Lang More easy.

2011-05-16 Thread Russel Winder
On Mon, 2011-05-16 at 22:54 +0800, Matthew Ong wrote: On 5/12/2011 7:19 PM, Russel Winder wrote: Hi Russel, I looked into this URL, http://www.russel.org.uk/Bazaar/ I put my little experimental codes in microbenchmarking in Bazaar branches accessible on my web site. Note this is

Re: reddit discussion about Go turns to D again

2011-05-16 Thread Adam D. Ruppe
Matthew Ong wrote: Hopefully, does D currently support such ability? [go interface] You can do it with templates. Most of Phobos' range functions are written in a similar style.

Re: reddit discussion about Go turns to D again

2011-05-16 Thread bearophile
Sean Kelly: std.paralellogrithm ;-) The module name I like more so far is the simple parallel_algorithm. But I don't mind the p prefix for the parallel function names. Bye, bearophile

Re: reddit discussion about Go turns to D again

2011-05-16 Thread Timon Gehr
bearophile wrote: Sean Kelly: std.paralellogrithm ;-) The module name I like more so far is the simple parallel_algorithm. But I don't mind the p prefix for the parallel function names. Bye, bearophile It is also possible to have both p prefix and identical names. The latter would be

Re: Making D Lang More easy.

2011-05-16 Thread bearophile
Russel Winder: If you want to branch the branch using Bazaar then use the URL http://www.russel.org.uk/Bazaar/Pi_Quadrature. If you want to browse the code then there is an instance of Loggerhead running so point your browser at the URL http://www.russel.org.uk:8080/Pi_Quadrature There's

Re: reddit discussion about Go turns to D again

2011-05-16 Thread Jonathan M Davis
bearophile wrote: Sean Kelly: std.paralellogrithm ;-) The module name I like more so far is the simple parallel_algorithm. But I don't mind the p prefix for the parallel function names. Bye, bearophile It is also possible to have both p prefix and identical names. The latter

Re: reddit discussion about Go turns to D again

2011-05-16 Thread Timon Gehr
Jonathan M Davis wrote: bearophile wrote: Sean Kelly: std.paralellogrithm ;-) The module name I like more so far is the simple parallel_algorithm. But I don't mind the p prefix for the parallel function names. Bye, bearophile It is also possible to have both p prefix

should int/short/byte implicitly cast to dchar/wchar/char?

2011-05-16 Thread Steven Schveighoffer
Currently, this works: void foo(dchar i) { } void main(string[] args) { foo(args.length); } Does this make any sense? When is it useful to be able to call a dchar-accepting function with a random integer? I would say dchar should be settable from an (unsigned) integer literal (for

Re: reddit discussion about Go turns to D again

2011-05-16 Thread Sean Kelly
On May 16, 2011, at 10:32 AM, Jonathan M Davis wrote: bearophile wrote: Sean Kelly: std.paralellogrithm ;-) The module name I like more so far is the simple parallel_algorithm. But I don't mind the p prefix for the parallel function names. Bye, bearophile It is also possible to have

Re: Making D Lang More easy.

2011-05-16 Thread Russel Winder
On Mon, 2011-05-16 at 13:32 -0400, bearophile wrote: Russel Winder: If you want to branch the branch using Bazaar then use the URL http://www.russel.org.uk/Bazaar/Pi_Quadrature. If you want to browse the code then there is an instance of Loggerhead running so point your browser at the

Re: reddit discussion about Go turns to D again

2011-05-16 Thread Jonathan M Davis
On May 16, 2011, at 10:32 AM, Jonathan M Davis wrote: bearophile wrote: Sean Kelly: std.paralellogrithm ;-) The module name I like more so far is the simple parallel_algorithm. But I don't mind the p prefix for the parallel function names. Bye, bearophile It is also

Re: reddit discussion about Go turns to D again

2011-05-16 Thread Andrej Mitrovic
Could templates in std.algorithm be expanded to have an optional thread-count compile-time argument? Maybe they'd be used like so: import std.stdio; import std.array; import std.range; import std.functional; enum Threads { x1 = 1, x2 = 2, x3 = 3, x4 = 4, // etc.. } void main()

Re: reddit discussion about Go turns to D again

2011-05-16 Thread Andrej Mitrovic
*actually a compile-time argument would be a bad idea, it's much more useful to know the core count at runtime, doh.

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Mehrdad
They're called Arrays, not Lists (or ArrayLists), so way would you expect a delete functions? I thought they're supposed to substitute for lists (otherwise we'd have an ArrayList type in Phobos). If you want something like an ArrayList in D, have a look at std.container.Array :-) That

Re: should int/short/byte implicitly cast to dchar/wchar/char?

2011-05-16 Thread Steven Schveighoffer
On Mon, 16 May 2011 13:51:55 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: Currently, this works: void foo(dchar i) { } void main(string[] args) { foo(args.length); } Damn, this originally started out as argc and argv, and I forgot how D accepts arguments, so I switched it

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Sean Kelly
On May 16, 2011, at 11:29 AM, Mehrdad wrote: As has been mentioned, std.algorithm.remove can be of help. You may want to look at three of its capabilities in particular: (a) remove multiple offsets in one pass, e.g. remove(a, 0, 4) removes the first and fifth element, (b) you can remove

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Timon Gehr
Thanks for the idea. This seems great, except for a couple of things: - I _do_ need the order to stay the same, so I can't just put in the last element. - I only need to remove one element at a time. - I still don't understand how this helps. Either this modifies the array directly, in

Re: reddit discussion about Go turns to D again

2011-05-16 Thread Andrei Alexandrescu
On 5/16/11 1:00 PM, Sean Kelly wrote: On May 16, 2011, at 10:32 AM, Jonathan M Davis wrote: bearophile wrote: Sean Kelly: std.paralellogrithm ;-) The module name I like more so far is the simple parallel_algorithm. But I don't mind the p prefix for the parallel function names. Bye,

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Russel Winder
On Mon, 2011-05-16 at 18:45 +, Timon Gehr wrote: [ . . . ] What exactly do you need the data structure for? I have to admit, my reaction was, and about b~ time someone asked that question. How on earth can one answer a question about data structures without knowing what the use case

Re: reddit discussion about Go turns to D again

2011-05-16 Thread Russel Winder
On Sun, 2011-05-15 at 13:41 -0700, Walter Bright wrote: On 5/15/2011 5:24 AM, Russel Winder wrote: On Sun, 2011-05-15 at 05:53 -0400, Gilbert Dawson wrote: [ . . . ] You could shed some llight on this if you're an expert. I don't know what's so different between actors and CSP. How does

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Andrei Alexandrescu
On 5/16/11 1:29 PM, Mehrdad wrote: As has been mentioned, std.algorithm.remove can be of help. You may want to look at three of its capabilities in particular: (a) remove multiple offsets in one pass, e.g. remove(a, 0, 4) removes the first and fifth element, (b) you can remove subranges, e.g.

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Andrej Mitrovic
You could try checking capacity() and using reserve() in non time-critical code.

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Mehrdad
1. Are you sure you need an array rather than a linked list? Yes. I'm only asking about a functionality already present in every other language I know (C++'s vector.erase, C#'s List.RemoveAt, Java's removeAt) so it's not something out of the blue. ;) 2. The garbage collector guarantees

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Mehrdad
Andrei: After you remove some elements from an array by using std.algorithm.remove, the array capacity stays the same. Sean: Removing and then appending one element to an array won't cause any allocations to occur. How is that possible, though? (See the example in my response to Timon.)

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Timon Gehr
1. Are you sure you need an array rather than a linked list? Yes. I'm only asking about a functionality already present in every other language I know (C++'s vector.erase, C#'s List.RemoveAt, Java's removeAt) so it's not something out of the blue. ;) 2. The garbage collector guarantees

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Steven Schveighoffer
On Mon, 16 May 2011 14:53:21 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 5/16/11 1:29 PM, Mehrdad wrote: As has been mentioned, std.algorithm.remove can be of help. You may want to look at three of its capabilities in particular: (a) remove multiple offsets in one

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread %u
Timon: What about: void removeAt(T)(ref T[] arr, size_t index) { foreach (i, ref item; arr[1 .. index+1]) item = arr[i - 1]; arr = arr[1 .. $]; //note how no valid data is beyond the end of the array } Clever, but if you do this with a big enough number of items, you'll exhaust

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Steven Schveighoffer
On Mon, 16 May 2011 15:12:17 -0400, Timon Gehr timon.g...@gmx.ch wrote: As an example, let's say I define: void removeAt(T)(ref T[] arr, size_t index) { foreach (i, ref item; arr[index .. $ - 1]) item = arr[i + 1]; arr = arr[0 .. $ - 1]; } and then I have: auto arr = [1, 2,

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Mehrdad
Steven: You need to do arr.assumeSafeAppend(); Otherwise, the runtime is no aware of your invalidation of the last element. See my edit on SO: http://stackoverflow.com/q/6015008/541686

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Timon Gehr
Mehrdad wrote: Timon: What about: void removeAt(T)(ref T[] arr, size_t index) { foreach (i, ref item; arr[1 .. index+1]) item = arr[i - 1]; arr = arr[1 .. $]; //note how no valid data is beyond the end of the array } Clever, but if you do this with a big enough number of

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Mehrdad
On 5/16/2011 12:25 PM, Timon Gehr wrote: Mehrdad wrote: Timon: What about: void removeAt(T)(ref T[] arr, size_t index) { foreach (i, ref item; arr[1 .. index+1]) item = arr[i - 1]; arr = arr[1 .. $]; //note how no valid data is beyond the end of the array } Clever, but if

Re: reddit discussion about Go turns to D again

2011-05-16 Thread Walter Bright
On 5/16/2011 11:51 AM, Russel Winder wrote: On Sun, 2011-05-15 at 13:41 -0700, Walter Bright wrote: I like to think of myself as an expert on this . . . you'll have to ask others if I actually am :-) I asked google, and they said 9,750 hits on Russel Winder Data Flow Concurrency !! Is that

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Steven Schveighoffer
On Mon, 16 May 2011 15:16:16 -0400, %u wfunct...@hotmail.com wrote: Timon: What about: void removeAt(T)(ref T[] arr, size_t index) { foreach (i, ref item; arr[1 .. index+1]) item = arr[i - 1]; arr = arr[1 .. $]; //note how no valid data is beyond the end of the array } Clever,

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Mehrdad
On 5/16/2011 12:25 PM, Andrei Alexandrescu wrote: On 5/16/11 2:25 PM, Timon Gehr wrote: Mehrdad wrote: Timon: What about: void removeAt(T)(ref T[] arr, size_t index) { foreach (i, ref item; arr[1 .. index+1]) item = arr[i - 1]; arr = arr[1 .. $]; //note how no valid data is beyond the end of

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Jonathan M Davis
On 2011-05-16 12:26, Mehrdad wrote: On 5/16/2011 12:25 PM, Timon Gehr wrote: Mehrdad wrote: Timon: What about: void removeAt(T)(ref T[] arr, size_t index) { foreach (i, ref item; arr[1 .. index+1]) item = arr[i - 1]; arr = arr[1 .. $]; //note

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Andrei Alexandrescu
On 5/16/11 2:31 PM, Mehrdad wrote: On 5/16/2011 12:25 PM, Andrei Alexandrescu wrote: On 5/16/11 2:25 PM, Timon Gehr wrote: Mehrdad wrote: Timon: What about: void removeAt(T)(ref T[] arr, size_t index) { foreach (i, ref item; arr[1 .. index+1]) item = arr[i - 1]; arr = arr[1 .. $]; //note

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Steven Schveighoffer
On Mon, 16 May 2011 15:23:31 -0400, Mehrdad wfunct...@hotmail.com wrote: Steven: You need to do arr.assumeSafeAppend(); Otherwise, the runtime is no aware of your invalidation of the last element. See my edit on SO: http://stackoverflow.com/q/6015008/541686 I'm not an SO user, so I'll

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Mehrdad
On 5/16/2011 12:38 PM, Andrei Alexandrescu wrote: Oh, I see. Wait, what bug are you referring to, though? I was mistaken and removed my post. The code ingeniously redefines the problem - instead of removing from the array by shifting its tail downwards, it shifts elements upwards from the head

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Andrei Alexandrescu
On 5/16/11 2:38 PM, Andrei Alexandrescu wrote: On 5/16/11 2:31 PM, Mehrdad wrote: On 5/16/2011 12:25 PM, Andrei Alexandrescu wrote: On 5/16/11 2:25 PM, Timon Gehr wrote: Mehrdad wrote: Timon: What about: void removeAt(T)(ref T[] arr, size_t index) { foreach (i, ref item; arr[1 .. index+1])

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Mehrdad
On 5/16/2011 12:41 PM, Andrei Alexandrescu wrote: I was mistaken and removed my post. The code ingeniously redefines the problem - instead of removing from the array by shifting its tail downwards, it shifts elements upwards from the head of the array. A nice hack, but I don't think it does a

Re: should int/short/byte implicitly cast to dchar/wchar/char?

2011-05-16 Thread KennyTM~
On May 17, 11 02:25, Steven Schveighoffer wrote: On Mon, 16 May 2011 13:51:55 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: Currently, this works: void foo(dchar i) { } void main(string[] args) { foo(args.length); } Damn, this originally started out as argc and argv, and I forgot

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Timon Gehr
In fact I even need to take that back. In order to work correctly, the function would have to iterate downwards. It _is_ indeed buggy, and I should stop emitting opinions when I'm short on time... Andrei Whoops, you are right: void removeAt(T)(ref T[] arr, size_t index) { foreach (i, ref

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Mehrdad
On 5/16/2011 12:53 PM, Timon Gehr wrote: In fact I even need to take that back. In order to work correctly, the function would have to iterate downwards. It _is_ indeed buggy, and I should stop emitting opinions when I'm short on time... Andrei Whoops, you are right: void removeAt(T)(ref T[]

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Timon Gehr
Timon Gehr wrote: void removeAt(T)(ref T[] arr, size_t index) { foreach (i, ref item; retro(arr[1 .. index+1])) item = arr[i - 1]; arr = arr[1 .. $]; } Sorry, still wrong: void removeAt(T)(ref T[] arr, size_t index) { foreach (i, ref item; retro(arr[1 .. index+1]))

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Steven Schveighoffer
On Mon, 16 May 2011 15:53:38 -0400, Timon Gehr timon.g...@gmx.ch wrote: In fact I even need to take that back. In order to work correctly, the function would have to iterate downwards. It _is_ indeed buggy, and I should stop emitting opinions when I'm short on time... Andrei Whoops, you are

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Andrei Alexandrescu
On 5/16/11 2:44 PM, Mehrdad wrote: On 5/16/2011 12:41 PM, Andrei Alexandrescu wrote: I was mistaken and removed my post. The code ingeniously redefines the problem - instead of removing from the array by shifting its tail downwards, it shifts elements upwards from the head of the array. A nice

Re: should int/short/byte implicitly cast to dchar/wchar/char?

2011-05-16 Thread Jonathan M Davis
On 2011-05-16 12:47, KennyTM~ wrote: On May 17, 11 02:25, Steven Schveighoffer wrote: On Mon, 16 May 2011 13:51:55 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: Currently, this works: void foo(dchar i) { } void main(string[] args) { foo(args.length); }

Re: should int/short/byte implicitly cast to dchar/wchar/char?

2011-05-16 Thread Steven Schveighoffer
On Mon, 16 May 2011 15:47:55 -0400, KennyTM~ kenn...@gmail.com wrote: On May 17, 11 02:25, Steven Schveighoffer wrote: On Mon, 16 May 2011 13:51:55 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: Currently, this works: void foo(dchar i) { } void main(string[] args) {

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Mehrdad
On 5/16/2011 12:53 PM, Andrei Alexandrescu wrote: On 5/16/11 2:44 PM, Mehrdad wrote: The function as implemented first assigns a[1]=a[0] and then a[2]=a[1], leading to [0, 0, 0, 3, 4] which is not what's needed. Oh yeah good point. Is there any way to find out if an array is a slice of

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Andrei Alexandrescu
On 5/16/11 2:56 PM, Timon Gehr wrote: Timon Gehr wrote: void removeAt(T)(ref T[] arr, size_t index) { foreach (i, ref item; retro(arr[1 .. index+1])) item = arr[i - 1]; arr = arr[1 .. $]; } Sorry, still wrong: void removeAt(T)(ref T[] arr, size_t index) { foreach (i,

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Timon Gehr
foreach is a very bad choice for solving this. I blindly took it over from the original code. Need to get some sleep :). This now definitely works, and is also the shortest: void removeAt(T)(ref T[] arr, size_t index){ for(auto i = index; i; i--) arr[i] = arr[i - 1]; arr = arr[1 .. $]; }

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Mehrdad
On 5/16/2011 12:59 PM, Andrei Alexandrescu wrote: On 5/16/11 2:56 PM, Timon Gehr wrote: I think it would take less time to actually paste the function in a file and try it. A cute possibility: void removeAt(T)(ref T[] arr, size_t index) { copy(retro(arr[0 .. index]), retro(arr[1 .. index +

Re: should int/short/byte implicitly cast to dchar/wchar/char?

2011-05-16 Thread KennyTM~
On May 17, 11 03:58, Steven Schveighoffer wrote: On Mon, 16 May 2011 15:47:55 -0400, KennyTM~ kenn...@gmail.com wrote: On May 17, 11 02:25, Steven Schveighoffer wrote: On Mon, 16 May 2011 13:51:55 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: Currently, this works: void foo(dchar

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Steven Schveighoffer
On Mon, 16 May 2011 15:52:23 -0400, Mehrdad wfunct...@hotmail.com wrote: On 5/16/2011 12:53 PM, Timon Gehr wrote: In fact I even need to take that back. In order to work correctly, the function would have to iterate downwards. It _is_ indeed buggy, and I should stop emitting opinions when I'm

Re: should int/short/byte implicitly cast to dchar/wchar/char?

2011-05-16 Thread Steven Schveighoffer
On Mon, 16 May 2011 16:06:34 -0400, KennyTM~ kenn...@gmail.com wrote: The compiler blindly accepts an 'int' as a 'dchar' argument, not -1. For instance, void main(){ string ret; ret ~= 0x10; // ok ret ~= 0x11; // Error: cannot append type int to type string int

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Andrei Alexandrescu
On 5/16/11 3:04 PM, Mehrdad wrote: On 5/16/2011 12:59 PM, Andrei Alexandrescu wrote: On 5/16/11 2:56 PM, Timon Gehr wrote: I think it would take less time to actually paste the function in a file and try it. A cute possibility: void removeAt(T)(ref T[] arr, size_t index) { copy(retro(arr[0 ..

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Timon Gehr
Andrei Alexandrescu wrote: A On 5/16/11 3:04 PM, Mehrdad wrote: On 5/16/2011 12:59 PM, Andrei Alexandrescu wrote: On 5/16/11 2:56 PM, Timon Gehr wrote: I think it would take less time to actually paste the function in a file and try it. A cute possibility: void removeAt(T)(ref T[] arr,

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Timon Gehr
Steven Schveighoffer wrote: On Mon, 16 May 2011 15:52:23 -0400, Mehrdad wfunct...@hotmail.com wrote: On 5/16/2011 12:53 PM, Timon Gehr wrote: In fact I even need to take that back. In order to work correctly, the function would have to iterate downwards. It _is_ indeed buggy, and I should

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Mehrdad
On 5/16/2011 1:15 PM, Vladimir Panteleev wrote: On Mon, 16 May 2011 23:11:50 +0300, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: I tested the function above. OP's intention was to create a version of removeAt which modifies the array in-place only when there are no other aliases

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Vladimir Panteleev
On Mon, 16 May 2011 23:11:50 +0300, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: I tested the function above. OP's intention was to create a version of removeAt which modifies the array in-place only when there are no other aliases towards the data. The initial approach was

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Steven Schveighoffer
On Mon, 16 May 2011 16:14:33 -0400, Timon Gehr timon.g...@gmx.ch wrote: Steven Schveighoffer wrote: On Mon, 16 May 2011 15:52:23 -0400, Mehrdad wfunct...@hotmail.com wrote: On 5/16/2011 12:53 PM, Timon Gehr wrote: In fact I even need to take that back. In order to work correctly, the

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Andrei Alexandrescu
On 5/16/11 3:15 PM, Vladimir Panteleev wrote: On Mon, 16 May 2011 23:11:50 +0300, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: I tested the function above. OP's intention was to create a version of removeAt which modifies the array in-place only when there are no other aliases

Re: Article Review: Migrating from std.date to std.datetime

2011-05-16 Thread Andrej Mitrovic
Fantastic work! I was lost in that std.datetime jungle for a while now. It's a great read (your English is pretty fluent!). Btw, I think there's a missing word in this sentence: If what you're doesn't need that extra boost of efficiency. (doing?).

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Steven Schveighoffer
On Mon, 16 May 2011 16:17:45 -0400, Mehrdad wfunct...@hotmail.com wrote: On 5/16/2011 1:15 PM, Vladimir Panteleev wrote: On Mon, 16 May 2011 23:11:50 +0300, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: I tested the function above. OP's intention was to create a version of

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Vladimir Panteleev
On Mon, 16 May 2011 23:22:21 +0300, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 5/16/11 3:15 PM, Vladimir Panteleev wrote: On Mon, 16 May 2011 23:11:50 +0300, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: I tested the function above. OP's intention was to

Re: Arrays are sufficient for ArrayLists? Really??

2011-05-16 Thread Mehrdad
On 5/16/2011 1:22 PM, Andrei Alexandrescu wrote: It does seem that all answers were ill-fitted to the way the problem has been ultimately formulated. Andrei Yeah, there's no clean answer to this that's of this form, so I'm just working around the problem. Thanks everybody for your input, I

Re: Article Review: Migrating from std.date to std.datetime

2011-05-16 Thread Jonathan M Davis
Fantastic work! I was lost in that std.datetime jungle for a while now. It's a great read (your English is pretty fluent!). I would hope so. I'm a native of California. English is my native language. I'd be more worried about my French fluency (which is good but likely deteriorating since I

Re: Implementing std.log

2011-05-16 Thread Jens Mueller
Andrei Alexandrescu wrote: On 5/9/11 1:52 AM, Andrei Alexandrescu wrote: [snip] I updated my std.log draft. Added a lot of features including formatted writing, delayed logging, and a variety of configuration options. Replaced the redundant log.xyz with logXyz. The implementation is

Re: should int/short/byte implicitly cast to dchar/wchar/char?

2011-05-16 Thread Nick Sabalausky
Steven Schveighoffer schvei...@yahoo.com wrote in message news:op.vvk48tn9eav7ka@localhost.localdomain... (int/short/byte can sometimes implicitly cast to dchar/wchar/char) What do you think? Ick! Kill it!

Re: reddit discussion about Go turns to D again

2011-05-16 Thread Nick Sabalausky
Matthew Ong on...@yahoo.com wrote in message news:iqr858$1eqa$1...@digitalmars.com... On 5/15/2011 5:56 PM, Timon Gehr wrote: I think D has difficulties getting new users, although it is superior to any programming language I know in almost every way. Yes. D has far more syntax and well

  1   2   >