extern and opaque structs

2012-05-02 Thread James Miller
struct. Adding __gshared doesn't help. I assume this is bug, since usage of extern means that I don't need to know the size, since it will be allocated in the C code, not the D code. -- James Miller

Re: FormatSpec struct

2012-04-13 Thread James Miller
for the standard format specifier, but its not very clear as to proper usage. I'm going to try to improve it and submit a pull request, until then looking at the source code for std.format should give you some idea of how to best use it. -- James Miller

Re: FormatSpec struct

2012-04-13 Thread James Miller
* James Miller ja...@aatch.net [2012-04-13 19:16:48 +1200]: * Paul D. Anderson paul.d.removethis.ander...@comcast.andthis.net [2012-04-13 07:50:31 +0200]: I'm trying to add formatted output to my decimal arithmetic module. Decimals should format like floating point, using 'E', 'F' and 'G

Re: Passing function as values and returning functions

2012-04-12 Thread James Miller
questions, not for people that are learning D. (High level questions being along the lines of What changes need to be made in dmd to support the new AA implementation?) -- James Miller

Re: Passing function as values and returning functions

2012-04-12 Thread James Miller
* James Miller ja...@aatch.net [2012-04-13 02:49:03 +1200]: Glad you got help Xan, but for future reference can you please keep questions to D.learn? It is somewhat frustrating to see the question How do I do that? on this list, since it is for discussion, and high-level questions

Re: Sampling algorithms for D

2012-04-12 Thread James Miller
() and (] to obtain the other two intervals -- James Miller

Re: Multiple %s format specifiers with a single argument

2012-04-11 Thread James Miller
posting using things like Windows Live Mail. And it seems that Outlook Express is better at mailing lists than Outlook, which is strange... -- James Miller

Re: Operator Overloading with class template

2012-04-09 Thread James Miller
a template instantiation of opBinary(/) for the type. That means that you can add on more template arguments. 3. Using `auto` means that the compiler works out the type, so you don't have to add extra template arguments to calculate the correct type. Hope that helps. -- James Miller

Re: making args global

2012-04-03 Thread James Miller
On 4 April 2012 10:32, jicman cabr...@wrc.xerox.com wrote: How can I make args global? thanks, In D, technically the only way is to use Runtime, as Andrej mentioned. As an aside, it is worth noting there is no global scope in D, module is as high as you go.

Re: Add Element to list not Working

2012-04-02 Thread James Miller
for arrays but apperantly not for lists. How do I add an element to a list? opAppend (or whatever it is) isn't defined for alot of types that it probably should be. There should be an append method that you can use though. -- James Miller

Re: Equivalents to policy classes in D

2012-04-02 Thread James Miller
you only want/need a minor change, I only use them for polymorphism in D. -- James Miller

Custom Allocators

2012-04-02 Thread James Miller
to write a completely GC-free application (using ref-counting instead for example)? Or would the GC still be used anyway? If I'm way off base on anything, feel free to say so, memory management and garbage collection aren't exactly my strong suits. Thanks -- James Miller

Re: UFCS for types?

2012-04-01 Thread James Miller
, not Uniform Template-Instantiation Syntax (UTIS?). Because even ext(T)(); is just sugar for: template ext(T) { void ext(); } -- James Miller

Re: std.typecons.Ref(T).opImplicitCastTo()

2012-04-01 Thread James Miller
On 31 March 2012 06:28, Jonathan M Davis jmdavisp...@gmx.com wrote: it also has opDot, which is being removed from the language. Out of curiosity, what was opDot? -- James Miller

Re: Get indexes of character in array

2012-03-28 Thread James Miller
On 28 March 2012 19:35, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: I'd like to get a list of indexes into an array that matches a character. E.g.: a foo a bar a.indexes(a) == [0, 6, 12] Anything like that in Phobos? std.regex might be able to produce something like it. -- James

Re: std.conv length=0

2012-03-28 Thread James Miller
like I did): I award thee the Necromancer badge, for reviving a long-dead thread. -- James Miller

Re: std.conv length=0

2012-03-28 Thread James Miller
On 29 March 2012 17:05, Jesse Phillips jessekphillip...@gmail.com wrote: On Thursday, 29 March 2012 at 03:40:55 UTC, James Miller wrote: I award thee the Necromancer badge, for reviving a long-dead thread. -- James Miller I find the distaste of reviving a thread strange. It would be like

Re: How to remove element from an SList?

2012-03-27 Thread James Miller
is that in order to remove, say the 5th element from a SList, you need to do this: SList!int s = [1,2,3,4,5,6,7,8,9,0]; auto r = s[0..4]; auto r1 = take(1, r); s.linearRemove(r1) Not the most intuitive way in the world... -- James Miller

Re: opDispatch(string name, E...) (E e) question.

2012-03-25 Thread James Miller
hoping you mean `fm.list = [1, abc, 4L, 3.33];` I think that using the right template parameters, you can use the same code for (T...)(T el) and (T)(T[]), I just can't remember what that is... Another question : How do I bring in : opDispatch(string name, T) (T[] t) -- James Miller

Re: opDispatch(string name, E...) (E e) question.

2012-03-25 Thread James Miller
fits into that properly, but it shouldn't be too hard. Also, remember that opDispatch takes the name of the function as the last parameter, so watch out for that. -- James Miller

Re: Vector operations optimization.

2012-03-23 Thread James Miller
where available, so it should be fast. -- James Miller

Re: regex issue

2012-03-20 Thread James Miller
, no strange other usages of the same escape sequence... -- James Miller

Comparison issue

2012-03-19 Thread James Miller
that the type of `v1` is `float`, as you'd expect. And the last one passes fine, as does doing `(v1+1)-1 == 1`. I'm not sure what could be causing this. I believe it may be a bug, but I would like to see if I'm just wrong instead. -- James Miller

Re: Comparison issue

2012-03-19 Thread James Miller
On Mar 20, 2012 1:50 AM, bearophile bearophileh...@lycos.com wrote: James Miller: writeln(v1 == 1); //false writeln(v1 == 1.0); //false writeln(v1 == 1.0f); //false writeln(v1+1 == 2.0f); //true Maybe I'd like to deprecate and then statically forbid

Re: Confused about github rebasing

2012-03-15 Thread James Miller
files. Also, git-svn isn't actually that bad... -- James Miller

Re: Confused about github rebasing

2012-03-15 Thread James Miller
-- James Miller

Re: Parse issue

2012-03-11 Thread James Miller
, it's 0 } I think parse should pop the first two characters if the string starts with 0x. Side-note, it would be nice if std.string.isNumeric took a radix. :) I agree, seems like a bug to me. -- James Miller

Re: Remarks on std.container

2012-03-08 Thread James Miller
On Thursday, March 08, 2012 10:21:48 Matthias Walter wrote: but the following did not work: std.algorithm.swap(arrayInstance[i], arrayInstance[j]); What error did you get exactly? Since that exact call should work. It didn't work doesn't help. -- James Miller

Re: [Inline assembler] Sequential `asm` blocks and return via EAX

2012-03-08 Thread James Miller
. I'd say that it would probably work, but you can't necessarily rely on that, you may have to live with a bit of code duplication. For 2. It seems that it should be fine, I can't check it right now, but I would be surprised if it didn't compile and run. -- James Miller

Re: Remarks on std.container

2012-03-08 Thread James Miller
On 8 March 2012 23:16, Matthias Walter xa...@xammy.homelinux.net wrote: On 03/08/2012 10:48 AM, James Miller wrote: On Thursday, March 08, 2012 10:21:48 Matthias Walter wrote: but the following did not work: std.algorithm.swap(arrayInstance[i], arrayInstance[j]); What error did you get

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-07 Thread James Miller
better and more intuitive. Because you don't describe things as -5 metres tall, so you don't describe things as -1024 bytes long. size_t makes sense unsigned because negatives make no sense for size. However, if you cast array.length to an int, it may work, haven't tested it. -- James Miller

Re: 0 negative loop condition bug or misunderstanding on my part

2012-03-07 Thread James Miller
language to D. -- James Miller

Re: Can I do an or in a version block?

2012-03-07 Thread James Miller
, probably because you are normally checking mutually exclusive version descriptions. Otherwise, its probably a good idea to keep the syntax as is, since it stops people from abusing the mechanic. -- James Miller

Re: Is there a wrapper for libuv?

2012-03-06 Thread James Miller
Do these already exist? sys/types is part of the C runtime if I remember correctly, and netinet/in.h is part of the Unix networking interface. You shouldn't have to do anything with them, just write bindings for the api, with all the correct types. -- James Miller

Re: Is there a wrapper for libuv?

2012-03-06 Thread James Miller
On 7 March 2012 14:47, Tyler Jameson Little beatgam...@gmail.com wrote: You shouldn't have to do anything with them, just write bindings for the api, with all the correct types. -- James Miller Thanks! I guess I got a little over-zealous in porting stuff over. I just need to create

Re: Cocoa bindings?

2012-03-01 Thread James Miller
On 2 March 2012 18:52, Alex Rønne Petersen xtzgzo...@gmail.com wrote: Hi, Are there any actively-maintained Cocoa bindings for D? -- - Alex Not as far as I know. You should make some! -- James Miller

Re: how to use raw sockets

2012-02-29 Thread James Miller
. Obviously you need to do a reasonable job, but it is only writing function prototypes, so there's not much that can go wrong. -- James Miller

Re: Regarding std.array.Appender

2012-02-29 Thread James Miller
should have used an Appender from the start. Now you have to go change all that code. Its your own fault really -- James Miller

Re: Why do bitfields throw exceptions instead of wrapping?

2012-02-29 Thread James Miller
than using a condition. Bitfields are for tightly packed data, and therefore expecting all language features to be available is missing the point. Hell bitfields are provided by templates, so they aren't even a part of the language, they are just a library feature. Hope that helps -- James Miller

Re: passing a string with the character as an argument

2012-02-28 Thread James Miller
, useful for gui programs and the like. I have tried your code, using a *nix shell, and using 3\ works. If you are on Windows, then I don't know why this is happening. -- James Miller

Re: Random behavior using a wrapped C library

2012-02-28 Thread James Miller
everything was compiled as x32. I don't know much, but wouldn't bigger register sizes mean that less data needs shuffled in and out of memory? Resulting in less instructions and therefore less memory usage? I'm just guessing though -- James Miller

Re: passing a string with the character as an argument

2012-02-28 Thread James Miller
On 29 February 2012 20:21, Jos van Uden user@domain.invalid wrote: On 29-2-2012 7:06, James Miller wrote: On 29 February 2012 18:51, jiccabr...@wrc.xerox.com  wrote: Greetings! I have this program, import std.process : system; import std.stdio; int main(char[][] args) {  char[] cmd

Re: Reflection

2012-02-27 Thread James Miller
, there might be, but not an obvious one. Its because templates can hold multiple types of declarations, not just functions or classes. The eponymous template pattern you see normally is not mandatory. -- James Miller

Re: produced binary is quite big

2012-02-26 Thread James Miller
On 26 February 2012 21:28, Jabba Laci jabba.l...@gmail.com wrote: Hi, I'm new to D. I tried the basic Hello World program (dmd hello.d) but it produced a 316 KB big binary. The same thing with C (gcc hello.c) is about 9 KB. Is there a way to reduce the size of the produced binary? Thanks,

Re: class templates and static if

2012-02-26 Thread James Miller
, then add specific functionality to the individual classes. It also allows for more reflection, which is easier and probably more powerful than conditional compilation. -- James Miller

Re: mixin template FAIL

2012-02-24 Thread James Miller
come close to D in terms of generics? I don't know, I'm just asking? Zach Lisp macros. But that's not a fair comparison, Lisp's object system was built using their macros... -- James Miller

Re: 2.058 broke my build. Is this a bug?

2012-02-24 Thread James Miller
On Feb 25, 2012 12:16 PM, Caligo iteronve...@gmail.com wrote: That was a typo, and it doesn't change anything. Here is a shorter version: 88 import std.datetime; import std.stdio; struct A{ auto fun(A a){ return 0; } } void bench(alias

Re: Weird opEquals Problem

2012-02-23 Thread James Miller
the language in more depth :) We don't mind. :-) T -- Truth, Sir, is a cow which will give [skeptics] no more milk, and so they are gone to milk the bull. -- Sam. Johnson Just don't start asking too stupid questions (like how does 1+1 work?) :P. -- James Miller

Re: Wrapping c variadic functions

2012-02-23 Thread James Miller
On 23 February 2012 23:35, simendsjo simend...@gmail.com wrote: Say i have a c function (didn't include first format argument for simplicity) void print(...); I wrap it up: extern(System) void print(...); And then I try to wrap it up in some safer D way: void print(Args...)(Args args) {

Re: D, Derelict2, and OpenGL

2012-02-23 Thread James Miller
I find that when learning a complicated system or library, the best way is to write out the code examples, compile them, then change things until they break, fix it, then make more changes. Eventually you end up with the worst code ever known to man and a thorough understanding of the system at

Re: D runtime Garbage Collector details

2012-02-23 Thread James Miller
or 2, but I know that there is a GC class with a bunch of methods on it for controlling the GC, including enabling and disabling it and getting GC-allocated memory. Whether that helps you write GC predictable code - I don't know, garbage collection is mostly a black art to me :-) -- James Miller

Re: Linking with d3d11.dll/lib

2012-02-23 Thread James Miller
system DLLs (for example, kernel32.dll). Note that this switch is not available via the ID I hope that helps, I don't actually do any windows programming so I can't test this at all -- James Miller

Re: Adding overloaded methods

2012-02-23 Thread James Miller
On 24 February 2012 12:06, H. S. Teoh hst...@quickfur.ath.cx wrote: On Fri, Feb 24, 2012 at 04:06:52AM +1300, James Miller wrote: On 23 February 2012 13:15, BLM blm...@gmail.com wrote: After messing around for a while, I figured out what is making DMD choke on my file. The methods were

Re: std.regex named matches

2012-02-21 Thread James Miller
On 22 February 2012 04:45, Dmitry Olshansky dmitry.o...@gmail.com wrote: On 21.02.2012 7:34, James Miller wrote: On 20 February 2012 21:34, Dmitry Olshanskydmitry.o...@gmail.com  wrote: 08.02.2012 13:07, James Miller пишет: Hi, I am using std.regex and using the named matches. I would

Re: inout problems

2012-02-21 Thread James Miller
On 22 February 2012 17:01, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: class Foo {    this(int) inout    { }    Foo makeFoo() { return new Foo(1); } } void main() { } test.d(8): Error: cannot implicitly convert expression (new Foo(1)) of type inout(Foo) to test.Foo Is this a

Re: std.regex named matches

2012-02-20 Thread James Miller
On 20 February 2012 21:34, Dmitry Olshansky dmitry.o...@gmail.com wrote: 08.02.2012 13:07, James Miller пишет: Hi, I am using std.regex and using the named matches. I would like to be able to get at the names that have matched, since this is library code. e.g.     auto m = match(test/2

Re: Removing items from an Array

2012-02-20 Thread James Miller
On 18 February 2012 05:30, Jonathan M Davis jmdavisp...@gmx.com wrote: On Friday, February 17, 2012 14:44:42 Mars wrote: On Friday, 17 February 2012 at 13:33:25 UTC, James Miller wrote: AAs don't keep the key order, so when you delete something out of it, what ever system iterates

Re: vim tips for D development

2012-02-19 Thread James Miller
I use vim, and I find that just vanilla vim does the job fine for me. I don't tend to use autocomplete unless its really smart (like using clang-complete for C/C++), and I should probably grab the latest D syntax file. mostly just judicious use of / and numbergg gets me most places.

Re: Removing items from an Array

2012-02-17 Thread James Miller
AAs don't keep the key order, so when you delete something out of it, what ever system iterates to the next pointer gets confused. Its generally a bad idea to modify an array as you loop through it. -- James Miller

Re: Chatting with a server

2012-02-14 Thread James Miller
the server and for user input at the same time, meaning that a slow server doesn't break your client or render it unusable. If the code works for you, then its probably fine. James Miller

Re: Anti-OOP... stupid?

2012-02-14 Thread James Miller
On 15 February 2012 12:12, H. S. Teoh hst...@quickfur.ath.cx wrote: On Tue, Feb 14, 2012 at 11:47:52PM +0100, Timon Gehr wrote: [...] It does not hurt at all if your code base is more flexible than necessary. [...] This needs to be taken in moderation, though. I've had to work with code

Re: Arrays - Inserting and moving data

2012-02-13 Thread James Miller
On 11 February 2012 10:45, Jonathan M Davis jmdavisp...@gmx.com wrote: On Friday, February 10, 2012 13:32:56 Marco Leise wrote: I know that feeling. I had no exposure to functional programming and options like chain never come to my head. Although map is a concept that I made friends with

Re: Arrays - Inserting and moving data

2012-02-13 Thread James Miller
On 14 February 2012 06:25, Timon Gehr timon.g...@gmx.ch wrote: On 02/13/2012 03:19 PM, James Miller wrote: On 11 February 2012 10:45, Jonathan M Davisjmdavisp...@gmx.com  wrote: On Friday, February 10, 2012 13:32:56 Marco Leise wrote: I know that feeling. I had no exposure to functional

Re: Instance-specific unittests

2012-02-13 Thread James Miller
On 14 February 2012 12:26, Jonathan M Davis jmdavisp...@gmx.com wrote: On Monday, February 13, 2012 15:12:15 H. S. Teoh wrote: I discovered something really cool today, and I thought I'd share it with my fellow learners: The unittest block is used for inserting unit tests that are executed at

Re: Arrays - Inserting and moving data

2012-02-13 Thread James Miller
On 14 February 2012 12:45, Ali Çehreli acehr...@yahoo.com wrote: On 02/13/2012 03:34 PM, James Miller wrote: Saying it is not quicksort as much as it may conceptually resemble quicksort is kinda odd, its like saying it is not a car, as much as it may conceptually resemble a car because

std.regex named matches

2012-02-08 Thread James Miller
; or something similar. I've looked at the library and I can't find anything of the sort, and you can't even use `foreach` to get at them that way, I'm guessing because you can have both integer and string indexes for the matches. Thanks James Miller

Re: How to reverse char[]?

2012-02-07 Thread James Miller
: true So if just just need an array of bytes and the `char' semantics are unimportant, then you can just use a ubyte instead. However Timon is correct that there should probably be a narrow string version of `reverse'. James Miller