Re: Import all?

2013-07-17 Thread JS
On Wednesday, 17 July 2013 at 17:51:15 UTC, Jonathan M Davis wrote: On Wednesday, July 17, 2013 11:34:56 JS wrote: Is is possible to import all modules using something import a.b.*;? I'd like to partition some modules up into smaller pieces to simplify modification(reduce scrolling) but, of cou

Re: foreach over split string

2013-07-17 Thread JS
On Thursday, 18 July 2013 at 05:57:48 UTC, H. S. Teoh wrote: On Thu, Jul 18, 2013 at 07:23:57AM +0200, JS wrote: [...] Thanks, this has made it much clearer. Something like foreach(a; StrSplit!(s)) foreach(b; StrSplit !(a)) does work because the second StrSplit uses a "ctfe-time variable"

Re: foreach over split string

2013-07-17 Thread H. S. Teoh
On Thu, Jul 18, 2013 at 07:23:57AM +0200, JS wrote: [...] > Thanks, this has made it much clearer. > > Something like > > foreach(a; StrSplit!(s)) >foreach(b; StrSplit !(a)) > > does work because the second StrSplit uses a "ctfe-time variable" > instead of a "template-time variable". > > My

Re: foreach over split string

2013-07-17 Thread JS
On Wednesday, 17 July 2013 at 23:56:11 UTC, H. S. Teoh wrote: On Thu, Jul 18, 2013 at 01:02:26AM +0200, JS wrote: [...] I can't put together a working example right now(other things to do) but the gist of the matter is: template strsplit(string n) { enum strsplit = std.string.split(n, ",");

Re: html documentation should show public imports

2013-07-17 Thread Jonathan M Davis
On Wednesday, July 17, 2013 17:39:19 Timothee Cour wrote: > std.range shouldn't contain public import std.array. It's done because otherwise std.range is useless with arrays, and arrays are probably the most frequently used type of range. We lose nothing by having that public import. Now, docume

Re: DLLs: Cleaning up

2013-07-17 Thread Ellery Newcomer
On 07/17/2013 08:13 AM, Chris wrote: with some nasty surprises as regards obtaining (valid) paths on Windows as opposed to Linux / Mac. Do tell. (Any time and life saving advice about linking to other libraries / DLLs?) Thanks everyone! celerid should be up to the task.

Re: html documentation should show public imports

2013-07-17 Thread bearophile
Timothee Cour: 1) html documentation should show public imports (sometimes such public imports make sense) 2) std.range shouldn't contain public import std.array. Sounds good. Bye, bearophile

html documentation should show public imports

2013-07-17 Thread Timothee Cour
std.range contains public import std.array. There are a few full module public imports like that in phobos. What's the rationale? I understand for hierarchical modules (breaking modules into packages) but for this? it's a bit confusing, as searching for 'array' in std.range docs yields nothing. My

Re: using opCmp

2013-07-17 Thread bearophile
Jaehunt: Does any have a idea for it? Unfortunately this is a design limitation of D operator overloading. I have shown this problem in the main D newsgroup lot of time ago. I don't remember the answer, but nothing changed. You can bring the problem again in the main D newsgroup... In th

Re: foreach over split string

2013-07-17 Thread H. S. Teoh
On Thu, Jul 18, 2013 at 01:02:26AM +0200, JS wrote: [...] > I can't put together a working example right now(other things to do) > but the gist of the matter is: > > template strsplit(string n) { enum strsplit = std.string.split(n, > ","); } > > ... inside a ctfe ... > > foreach(n; strsplit!(s))

using opCmp

2013-07-17 Thread Jaehunt
Hi, I tried to compare two sets by opCmp, but I couldn't get correct outputs. Does anyone help me? I have same sets of set S1 = [1,2,3] and S2 = [1,2,3]. Output of S1I can't make a difference between two sets by if statements, so I can't make different output. Does any have a idea for it?

Re: foreach over split string

2013-07-17 Thread JS
On Wednesday, 17 July 2013 at 18:00:15 UTC, Jonathan M Davis wrote: On Wednesday, July 17, 2013 16:02:00 JS wrote: foreach(n; std.string.split(s, ",")) { // n can't be read at compile time } using in a ctfe. How to loop over a string array in a ctfe? I would point out that if you're just spl

Re: "Previous Definition different" when -inline switch is set

2013-07-17 Thread Ali Çehreli
On 07/17/2013 07:01 AM, Baz wrote: > Hello, is there any particular reason why dmd would tell me that the > "Previous Definition different" when compiling a program with -inline > while not when compiling it without the switch ? I could not find that phrase in the dmd, dlang, or phobos sources.

Re: "Previous Definition different" when -inline switch is set

2013-07-17 Thread John Colvin
On Wednesday, 17 July 2013 at 20:58:41 UTC, Baz wrote: On Wednesday, 17 July 2013 at 18:00:47 UTC, Jonathan M Davis wrote: On Wednesday, July 17, 2013 16:01:23 Baz wrote: Is the bug described a "well known" issue with a "well known" workaround ? (so far, I haven't found anything which is relate

Re: "Previous Definition different" when -inline switch is set

2013-07-17 Thread Baz
On Wednesday, 17 July 2013 at 18:00:47 UTC, Jonathan M Davis wrote: On Wednesday, July 17, 2013 16:01:23 Baz wrote: Is the bug described a "well known" issue with a "well known" workaround ? (so far, I haven't found anything which is related, even with some serious forum/newsgroup investigation.

Re: What is the correct way to test for an empty string?

2013-07-17 Thread H. S. Teoh
On Wed, Jul 17, 2013 at 09:18:27PM +0200, Rob T wrote: > On Tuesday, 16 July 2013 at 19:33:13 UTC, bearophile wrote: > > > >The right, safe and readable way is to use std.array.empty: > > > >if (myString.empty) > > > >If you don't want to import functions, then test for the length: > > > >if (strin

Re: What is the correct way to test for an empty string?

2013-07-17 Thread Jesse Phillips
On Wednesday, 17 July 2013 at 19:18:29 UTC, Rob T wrote: What was the rational for empty not being built in? Is there a performance penalty using "empty"? --rt empty() was added to provide a range interface to arrays. Probably wasn't built in since you have to handle all array types. The co

Re: Import all?

2013-07-17 Thread Jesse Phillips
On Wednesday, 17 July 2013 at 11:45:09 UTC, monarch_dodra wrote: //main.d import a; void main() { foo(); //OK bar(); //OK a.foo(); //OK (!!!) a.bar(); //OK (!!!) a.b.foo(); //OK a.c.bar(); //OK } //=== To be frank, I don't know if this is a bug

Re: What is the correct way to test for an empty string?

2013-07-17 Thread Rob T
On Tuesday, 16 July 2013 at 19:33:13 UTC, bearophile wrote: The right, safe and readable way is to use std.array.empty: if (myString.empty) If you don't want to import functions, then test for the length: if (string.length == 0) Bye, bearophile What was the rational for empty not being bui

Re: Payload structure problem using inline asm

2013-07-17 Thread Baz
On Wednesday, 17 July 2013 at 17:11:20 UTC, John Colvin wrote: On Wednesday, 17 July 2013 at 17:09:30 UTC, John Colvin wrote: On Wednesday, 17 July 2013 at 16:52:40 UTC, Baz wrote: Hello, I've defined a simple template used in a double linked list implementation: template tDLListItem(T) {

Re: "Previous Definition different" when -inline switch is set

2013-07-17 Thread Jonathan M Davis
On Wednesday, July 17, 2013 16:01:23 Baz wrote: > Is the bug described a "well known" issue with a "well known" > workaround ? > (so far, I haven't found anything which is related, even with > some serious forum/newsgroup investigation...) I don't know if this particular issue with -inline is in b

Re: foreach over split string

2013-07-17 Thread Jonathan M Davis
On Wednesday, July 17, 2013 16:02:00 JS wrote: > foreach(n; std.string.split(s, ",")) > { > // n can't be read at compile time > } > > using in a ctfe. > > How to loop over a string array in a ctfe? I would point out that if you're just splitting a string to iterate over it, then you should pro

Re: Are associative arrays stable in D?

2013-07-17 Thread Ali Çehreli
On 07/17/2013 10:21 AM, Yota wrote: > On Wednesday, 17 July 2013 at 09:48:06 UTC, monarch_dodra wrote: >> I find it disturbing that the built-in property "keys" would dup an >> entire array, and then copy all the keys into that array, whereas the >> function "byKeys()" will simply allow you to it

Re: Import all?

2013-07-17 Thread Jonathan M Davis
On Wednesday, July 17, 2013 11:34:56 JS wrote: > Is is possible to import all modules using something import > a.b.*;? > > I'd like to partition some modules up into smaller pieces to > simplify modification(reduce scrolling) but, of course, this > increases the number of imports drastically. Thi

Re: Are associative arrays stable in D?

2013-07-17 Thread Jonathan M Davis
On Wednesday, July 17, 2013 19:21:03 Yota wrote: > On Wednesday, 17 July 2013 at 09:48:06 UTC, monarch_dodra wrote: > > I find it disturbing that the built-in property "keys" would > > dup an entire array, and then copy all the keys into that > > array, whereas the function "byKeys()" will simply a

Re: Are associative arrays stable in D?

2013-07-17 Thread Yota
On Wednesday, 17 July 2013 at 09:48:06 UTC, monarch_dodra wrote: I find it disturbing that the built-in property "keys" would dup an entire array, and then copy all the keys into that array, whereas the function "byKeys()" will simply allow you to iterate on the keys. "keys" is in blatant vio

Re: Payload structure problem using inline asm

2013-07-17 Thread John Colvin
On Wednesday, 17 July 2013 at 17:09:30 UTC, John Colvin wrote: On Wednesday, 17 July 2013 at 16:52:40 UTC, Baz wrote: Hello, I've defined a simple template used in a double linked list implementation: template tDLListItem(T) { const cPrevOffs = size_t.sizeof; const cNextOffs =

Re: Payload structure problem using inline asm

2013-07-17 Thread John Colvin
On Wednesday, 17 July 2013 at 16:52:40 UTC, Baz wrote: Hello, I've defined a simple template used in a double linked list implementation: template tDLListItem(T) { const cPrevOffs = size_t.sizeof; const cNextOffs = size_t.sizeof + size_t.sizeof; void* NewItemCaps(T* aDat

Payload structure problem using inline asm

2013-07-17 Thread Baz
Hello, I've defined a simple template used in a double linked list implementation: template tDLListItem(T) { const cPrevOffs = size_t.sizeof; const cNextOffs = size_t.sizeof + size_t.sizeof; void* NewItemCaps(T* aData, void* aPrevious, void* aNext) {

Re: foreach over split string

2013-07-17 Thread John Colvin
On Wednesday, 17 July 2013 at 16:19:46 UTC, Maxim Fomin wrote: On Wednesday, 17 July 2013 at 15:26:19 UTC, John Colvin wrote: I think I can speak quite safely for the majority of the community when I say that you are only welcome here if you can keep your aggressive and disrespectful comments t

Re: foreach over split string

2013-07-17 Thread Maxim Fomin
On Wednesday, 17 July 2013 at 15:26:19 UTC, John Colvin wrote: I think I can speak quite safely for the majority of the community when I say that you are only welcome here if you can keep your aggressive and disrespectful comments to yourself. I think you cannot, as nobody provided you such ri

Re: foreach over split string

2013-07-17 Thread Artur Skawina
On 07/17/13 16:38, JS wrote: > it is is a lot of work to simplify my code to something that will make sense Indeed. > If it will make you feel better to see some code, which does work, [...snipped incomplete example which doesn't...] > template tSplitStr(string n, string d = " ") { enum tSpl

Re: Source code output

2013-07-17 Thread John Colvin
On Wednesday, 17 July 2013 at 05:29:26 UTC, H. S. Teoh wrote: On Wed, Jul 17, 2013 at 05:27:34AM +0200, JS wrote: With heavy ctfe code generation usage is it possible to have the d compiler output the source code after all mixin templates have been "used"? This way it is easier to visually chec

Re: foreach over split string

2013-07-17 Thread anonymous
On Wednesday, 17 July 2013 at 15:18:03 UTC, JS wrote: On Wednesday, 17 July 2013 at 14:55:12 UTC, Ary Borenszweig wrote: [...] If you think the language is shitty why are you using it? You didn't pay for D, you are receiving it as a free tool. I don't think many people will help you if you co

Re: foreach over split string

2013-07-17 Thread JS
On Wednesday, 17 July 2013 at 14:55:12 UTC, Ary Borenszweig wrote: On 7/17/13 11:38 AM, JS wrote: On Wednesday, 17 July 2013 at 14:18:25 UTC, John Colvin wrote: On Wednesday, 17 July 2013 at 14:09:28 UTC, JS wrote: Ok, spoke too soon again, my string requires compound splitting: foreach(ss;

Re: Source code output

2013-07-17 Thread Jacob Carlborg
On 2013-07-17 16:13, Ary Borenszweig wrote: Since Descent used a port of the D compiler to Java, I think the same can be done by tweaking dmd. You have the generated AST after semantic analysis and you can easily output that. But of course you need to be able to convert the AST to string with co

Re: foreach over split string

2013-07-17 Thread John Colvin
On Wednesday, 17 July 2013 at 15:18:03 UTC, JS wrote: On Wednesday, 17 July 2013 at 14:55:12 UTC, Ary Borenszweig wrote: On 7/17/13 11:38 AM, JS wrote: On Wednesday, 17 July 2013 at 14:18:25 UTC, John Colvin wrote: On Wednesday, 17 July 2013 at 14:09:28 UTC, JS wrote: Ok, spoke too soon again

Re: DLLs: Cleaning up

2013-07-17 Thread Chris
On Monday, 15 July 2013 at 15:59:42 UTC, Chris wrote: On Monday, 15 July 2013 at 15:26:49 UTC, Ellery Newcomer wrote: On 07/15/2013 07:18 AM, Chris wrote: doesn't work with newer versions of dmd does too. (I'm the maintainer) https://bitbucket.org/ariovistus/pyd Thank you very much (I used

Re: foreach over split string

2013-07-17 Thread Ary Borenszweig
On 7/17/13 11:38 AM, JS wrote: On Wednesday, 17 July 2013 at 14:18:25 UTC, John Colvin wrote: On Wednesday, 17 July 2013 at 14:09:28 UTC, JS wrote: Ok, spoke too soon again, my string requires compound splitting: foreach(ss; split(s, ",")) { split(ss, "|"); // ss can't be read at compile t

Re: foreach over split string

2013-07-17 Thread JS
On Wednesday, 17 July 2013 at 14:18:25 UTC, John Colvin wrote: On Wednesday, 17 July 2013 at 14:09:28 UTC, JS wrote: Ok, spoke too soon again, my string requires compound splitting: foreach(ss; split(s, ",")) { split(ss, "|"); // ss can't be read at compile time although I can use ss direc

Re: foreach over split string

2013-07-17 Thread John Colvin
On Wednesday, 17 July 2013 at 14:09:28 UTC, JS wrote: Ok, spoke too soon again, my string requires compound splitting: foreach(ss; split(s, ",")) { split(ss, "|"); // ss can't be read at compile time although I can use ss directly string a = ss; // works fine. } Is there any possibi

Re: Source code output

2013-07-17 Thread Ary Borenszweig
On 7/17/13 4:33 AM, Jacob Carlborg wrote: On 2013-07-17 05:27, JS wrote: With heavy ctfe code generation usage is it possible to have the d compiler output the source code after all mixin templates have been "used"? This way it is easier to visually check for errors in the generated code. I ima

Re: foreach over split string

2013-07-17 Thread JS
Ok, spoke too soon again, my string requires compound splitting: foreach(ss; split(s, ",")) { split(ss, "|"); // ss can't be read at compile time although I can use ss directly string a = ss; // works fine. }

Re: foreach over split string

2013-07-17 Thread JS
On Wednesday, 17 July 2013 at 14:02:01 UTC, JS wrote: foreach(n; std.string.split(s, ",")) { // n can't be read at compile time } using in a ctfe. How to loop over a string array in a ctfe? Strange... The code actually works, but when I use my wrapper template it doesn't... template

"Previous Definition different" when -inline switch is set

2013-07-17 Thread Baz
Hello, is there any particular reason why dmd would tell me that the "Previous Definition different" when compiling a program with -inline while not when compiling it without the switch ? more information: - the message appears two times and it's about two methods used in a lib. - the message

foreach over split string

2013-07-17 Thread JS
foreach(n; std.string.split(s, ",")) { // n can't be read at compile time } using in a ctfe. How to loop over a string array in a ctfe?

Re: Sorting according to a primary and secondary criterion

2013-07-17 Thread monarch_dodra
On Wednesday, 17 July 2013 at 13:12:18 UTC, Joseph Rushton Wakeling wrote: On 07/17/2013 02:42 PM, bearophile wrote: You need a lambda delegate for that. But I forgot about multisort algorithm... It's probably the right tool. So, in the end I tried out 3 different alternatives: schwartzSor

Re: Sorting according to a primary and secondary criterion

2013-07-17 Thread Joseph Rushton Wakeling
On 07/17/2013 02:42 PM, bearophile wrote: > You need a lambda delegate for that. But I forgot about multisort algorithm... > It's probably the right tool. So, in the end I tried out 3 different alternatives: schwartzSort(a => tuple(arr1[a], arr2[a]), "a < b") sort((a, b) => arr1[a] < arr1[b]

Re: Sorting according to a primary and secondary criterion

2013-07-17 Thread bearophile
Joseph Rushton Wakeling: Actually, I don't find it needs any more memory than regular schwartzSort (which I was using anyway), A and array of tuples should take more memory. Try with a much larger input array. but it does cost _speed_ -- quite a lot. :-( Right, schwartzSort is quite slo

Re: Sorting according to a primary and secondary criterion

2013-07-17 Thread Joseph Rushton Wakeling
On 07/17/2013 02:07 PM, bearophile wrote: > Another way is to use something like this, but this needs some memory: > > idx.schwartzSort!(i => tuple(arr1[i], arr2[i])); Actually, I don't find it needs any more memory than regular schwartzSort (which I was using anyway), but it does cost _speed_ --

Re: Sorting according to a primary and secondary criterion

2013-07-17 Thread Joseph Rushton Wakeling
On 07/17/2013 02:35 PM, John Colvin wrote: > Is std.algorithm.multisort what you'd be looking for? Good thought. Thanks to pointing me here I also noticed the following example in the schwartzSort docs which might be relevant: sort!((a, b) => hashFun(a) < hashFun(b))(array); I'm going to tr

Re: Sorting according to a primary and secondary criterion

2013-07-17 Thread bearophile
Joseph Rushton Wakeling: idx.sort!("arr1[a] < arr1[b] || (arr1[a] == arr1[b] && arr2[a] < arr2[b])"); I (unsurprisingly) get a load of errors about std.functional not having access to arr1 or arr2. You need a lambda delegate for that. But I forgot about multisort algorithm... It's prob

Re: Sorting according to a primary and secondary criterion

2013-07-17 Thread John Colvin
On Wednesday, 17 July 2013 at 11:43:37 UTC, Joseph Rushton Wakeling wrote: .sort!("arr1[a] < arr1[b] || (arr1[a] == arr1[b] && arr2[a] < arr2[b]")); ... but I'm not sure that would be an optimal strategy. Is std.algorithm.multisort what you'd be looking for?

Re: Sorting according to a primary and secondary criterion

2013-07-17 Thread Joseph Rushton Wakeling
On 07/17/2013 02:07 PM, bearophile wrote: > Another way is to use something like this, but this needs some memory: > > idx.schwartzSort!(i => tuple(arr1[i], arr2[i])); Oh, nice thought! :-) > But often the most efficient way is to use sort() with a comparison function > that takes in account all

Re: Sorting according to a primary and secondary criterion

2013-07-17 Thread bearophile
Joseph Rushton Wakeling: Is there a standard, accepted approach for this kind of sort with primary/secondary criterion? There are various ways to do it. One way is to use a stable sort and sort the data two or more times. Another way is to use something like this, but this needs some memor

Re: Import all?

2013-07-17 Thread monarch_dodra
On Wednesday, 17 July 2013 at 10:04:53 UTC, JS wrote: On Wednesday, 17 July 2013 at 09:57:04 UTC, monarch_dodra wrote: On Wednesday, 17 July 2013 at 09:34:58 UTC, JS wrote: Is is possible to import all modules using something import a.b.*;? I'd like to partition some modules up into smaller p

Sorting according to a primary and secondary criterion

2013-07-17 Thread Joseph Rushton Wakeling
Hi all :-) Suppose that I have two different arrays of the same length, arr1 and arr2, and an array of index values idx = [0 .. arr1.length]. Now, suppose that I want to sort the index values according to the corresponding values of arr1. This is easy with schwartzSort: idx.schwartzSort!(a

Re: Import all?

2013-07-17 Thread JS
On Wednesday, 17 July 2013 at 09:57:04 UTC, monarch_dodra wrote: On Wednesday, 17 July 2013 at 09:34:58 UTC, JS wrote: Is is possible to import all modules using something import a.b.*;? I'd like to partition some modules up into smaller pieces to simplify modification(reduce scrolling) but,

Re: Import all?

2013-07-17 Thread monarch_dodra
On Wednesday, 17 July 2013 at 09:34:58 UTC, JS wrote: Is is possible to import all modules using something import a.b.*;? I'd like to partition some modules up into smaller pieces to simplify modification(reduce scrolling) but, of course, this increases the number of imports drastically. I

Re: Import all?

2013-07-17 Thread JS
On Wednesday, 17 July 2013 at 09:54:28 UTC, JS wrote: On Wednesday, 17 July 2013 at 09:34:58 UTC, JS wrote: Is is possible to import all modules using something import a.b.*;? I'd like to partition some modules up into smaller pieces to simplify modification(reduce scrolling) but, of course,

Re: Import all?

2013-07-17 Thread JS
On Wednesday, 17 July 2013 at 09:34:58 UTC, JS wrote: Is is possible to import all modules using something import a.b.*;? I'd like to partition some modules up into smaller pieces to simplify modification(reduce scrolling) but, of course, this increases the number of imports drastically. T

Re: Are associative arrays stable in D?

2013-07-17 Thread monarch_dodra
On Wednesday, 17 July 2013 at 08:31:00 UTC, Mike Parker wrote: On Tuesday, 16 July 2013 at 19:37:14 UTC, Gary Willoughby wrote: If however you remove the .byKey() call and use .keys instead, it works! With byKey, you are iterating over a range of original key values, meaning that attempt

Import all?

2013-07-17 Thread JS
Is is possible to import all modules using something import a.b.*;? I'd like to partition some modules up into smaller pieces to simplify modification(reduce scrolling) but, of course, this increases the number of imports drastically.

Re: request for a RSS feed of the D Forum

2013-07-17 Thread Mike Parker
On Tuesday, 16 July 2013 at 16:33:54 UTC, JohnnyK wrote: I could not find any posts on this and have not found a link on the site about this either. It would be nice if there was a RSS feed for the forum at least for the announce forum. It is very difficult to monitor changes and updates with

Re: Are associative arrays stable in D?

2013-07-17 Thread Mike Parker
On Tuesday, 16 July 2013 at 19:37:14 UTC, Gary Willoughby wrote: If however you remove the .byKey() call and use .keys instead, it works! With byKey, you are iterating over a range of original key values, meaning that attempting to remove any of them will result in bad bahavior. With .ke

Re: Source code output

2013-07-17 Thread Jacob Carlborg
On 2013-07-17 05:27, JS wrote: With heavy ctfe code generation usage is it possible to have the d compiler output the source code after all mixin templates have been "used"? This way it is easier to visually check for errors in the generated code. I imagine one could use pragma in a "special way

Re: Source code output

2013-07-17 Thread dennis luehring
Am 17.07.2013 09:33, schrieb Jacob Carlborg: On 2013-07-17 05:27, JS wrote: With heavy ctfe code generation usage is it possible to have the d compiler output the source code after all mixin templates have been "used"? This way it is easier to visually check for errors in the generated code. I