Re: bigint - python long

2012-09-06 Thread Ellery Newcomer
On 09/05/2012 11:19 PM, Jacob Carlborg wrote: On 2012-09-06 04:10, bearophile wrote: There are several important cases, like: Some D lazy ranges == Python lazy iterators/generators array.array == D arrays NumPy arrays == D arrays Associative arrays? check.

Re: bigint - python long

2012-09-06 Thread Ellery Newcomer
On 09/06/2012 04:11 AM, bearophile wrote: Ellery Newcomer: array.array == D arrays just checked, looks like we have it: PyStmts(q{from array import array; a = array('i', [44,33,22,11]);}, testing); assert(PyEval!(int[])(a, testing) == [44,33,22,11]); I think if the python object

bigint - python long

2012-09-05 Thread Ellery Newcomer
Hey. Investigating the possibility of providing this conversion in pyd. Python provides an api for accessing the underlying bytes. std.bigint seemingly doesn't. Am I missing anything?

Re: bigint - python long

2012-09-05 Thread Ellery Newcomer
On 09/05/2012 05:02 PM, bearophile wrote: Ellery Newcomer: Investigating the possibility of providing this conversion in pyd. Are you updating Pyd? :-) Bye, bearophile Yep. Have any suggestions for supported conversion out of the box? From the standard library, I already have Complex

Re: bigint - python long

2012-09-05 Thread Ellery Newcomer
On 09/05/2012 07:10 PM, bearophile wrote: Some D lazy ranges == Python lazy iterators/generators I'll look into this one. array.array == D arrays just checked, looks like we have it: PyStmts(q{from array import array; a = array('i', [44,33,22,11]);}, testing); assert(PyEval!(int[])(a,

Re: Trait to get function parameter names

2012-09-04 Thread Ellery Newcomer
On 08/31/2012 12:48 PM, mist wrote: On Friday, 31 August 2012 at 19:15:14 UTC, Jacob Carlborg wrote: On 2012-08-31 16:24, mist wrote: Subject. Is that possible? I see only parameter type tuple stuff out there. I'm looking into iterating over own parameter name list inside of function. Here:

Re: Trait to get function parameter names

2012-09-04 Thread Ellery Newcomer
On 09/04/2012 12:09 PM, Jacob Carlborg wrote: On 2012-09-04 20:28, Ellery Newcomer wrote: Have fun discovering it isn't implemented. Then use It isn't? Then why is it in the docs. no idea. std.traits.ParameterIdentifierTuple And why is this not in the docs. dlang.org docs seem

modulename

2012-09-04 Thread Ellery Newcomer
anybody know a neat trick to get the module name that a function is being called in a la void foobar(size_t line = __LINE__) { } std.traits.moduleName looks like it almost does it, but it needs a symbol from the module.

Re: modulename

2012-09-04 Thread Ellery Newcomer
On 09/04/2012 12:41 PM, Andrej Mitrovic wrote: __FILE__? It doesn't necessarily have the exact package hierarchy. e.g: // wonka.d module willy.wonka; pragma(msg, __FILE__); // end wonka.d dmd wonka.d gives wonka.d but dmd willy/wonka.d gives willy/wonka.d

Re: modulename

2012-09-04 Thread Ellery Newcomer
On 09/04/2012 01:16 PM, Jonathan M Davis wrote: On Tuesday, September 04, 2012 21:41:24 Andrej Mitrovic wrote: __FILE__? That'll mostly work, but it's perfectly possible to give a module a name which is completely different from the file name. But it looks like we now have

segfault

2012-08-31 Thread Ellery Newcomer
hey, is anyone else getting a segfault from dmd on this code? struct a{ static if(i) { }elseenum z = ; } 2.060 x64 linux and if they do, I call dibs on the bug report

Re: segfault

2012-08-31 Thread Ellery Newcomer
On 08/31/2012 03:18 PM, Andrej Mitrovic wrote: On 8/31/12, Ellery Newcomer ellery-newco...@utulsa.edu wrote: hey, is anyone else getting a segfault from dmd on this code? Yep on win32. thanks

Re: abnormal program termination

2012-08-30 Thread Ellery Newcomer
On Thursday, 30 August 2012 at 13:39:30 UTC, Regan Heath wrote: Where did you find that.. I still can't find the blasted thing :p void dmd_51d770(char* msg, char* title) { at address 0x51d770 in the _TEXT section (in a slightly less disassembled form) apparently I'm not the first

Re: abnormal program termination

2012-08-29 Thread Ellery Newcomer
On 08/28/2012 01:03 PM, Ellery Newcomer wrote: On 08/28/2012 09:55 AM, Regan Heath wrote: I searched the DMD sources, just in case the message abnormal program termination was DMD specific, and I found nothing. Then I searched all files and the string appears in the dmd.exe binary

Re: abnormal program termination

2012-08-28 Thread Ellery Newcomer
On 08/28/2012 06:37 AM, Regan Heath wrote: On Sat, 25 Aug 2012 01:10:05 +0100, Ellery Newcomer ellery-newco...@utulsa.edu wrote: I am running into an ICE on windows - Assertion Failure on such-and-such line in mtype.c - and I am trying to get a test command for to reduce

Re: abnormal program termination

2012-08-28 Thread Ellery Newcomer
On 08/28/2012 09:55 AM, Regan Heath wrote: I searched the DMD sources, just in case the message abnormal program termination was DMD specific, and I found nothing. Then I searched all files and the string appears in the dmd.exe binary, making me suspect the compiler used to produce dmd.exe

Re: how to get fully qualified name of a template function (if possible at CT)

2012-08-27 Thread Ellery Newcomer
On 08/24/2012 11:16 PM, timotheecour wrote: how to get fully qualified name of a template function? In the code below I want to get util.mod.mymethod!(double) I tried everything (see below) to no avail, it just returns mymethod; The closest I get is demangle(mangledName!(fun)), which shouldn't

celerid and cygwin

2012-08-25 Thread Ellery Newcomer
I almost have celerid building extension modules with dmd under cygwin. The issue now is linking to python. With normal windows, it's easy enough to convert libs/pythonXY.lib to OMF. With cygwin, we have /usr/lib/pythonX.Y/config/pythonX.Y.dll.a. Don't know what to do with that. My

Re: call member function alias

2012-08-24 Thread Ellery Newcomer
On 08/23/2012 11:47 PM, Jacob Carlborg wrote: How about this: import std.stdio; class Foo { auto forward (alias fn, Args...) (Args args) { return fn(args); } void bar (int a = 3) { writeln(bar , a); } } auto call (alias fn, T, Args...) (T t,

abnormal program termination

2012-08-24 Thread Ellery Newcomer
I am running into an ICE on windows - Assertion Failure on such-and-such line in mtype.c - and I am trying to get a test command for to reduce it with the redoubtable dustmite. Normally, 'abnormal program termination' is printed to the console; however if I try to redirect stderr for greppage

call member function alias

2012-08-23 Thread Ellery Newcomer
if I have a member function alias and corresponding object and arguments, is there any way to turn them into a member function call? e.g. class X{ void a(); } auto profit(alias fn, T, Args...)(T t, Args args) { ??? } profit!(X.fn, X)(x); Constraints are: 1) must conserve ability to omit

function pointer and default argument

2012-08-22 Thread Ellery Newcomer
hey. is this valid code? void func1(int i, double j = 1.0) { } void main() { auto fn = func1; func1(1); //dmd: ok fn(1); // dmd: not ok }

Re: function pointer and default argument

2012-08-22 Thread Ellery Newcomer
On 08/22/2012 12:03 PM, Ali Çehreli wrote: On 08/22/2012 11:51 AM, Ellery Newcomer wrote: hey. is this valid code? void func1(int i, double j = 1.0) { } void main() { auto fn = func1; func1(1); //dmd: ok fn(1); // dmd: not ok } The type of the function pointer does

Re: where is parameterNames?

2012-08-19 Thread Ellery Newcomer
On 08/15/2012 09:46 AM, David Nadlinger wrote: Related: https://github.com/D-Programming-Language/phobos/blob/master/std/traits.d#L510 David That should work nicely. Why does it not show up on dlang.org?

Re: prevent multiple calls to rt_term

2012-08-13 Thread Ellery Newcomer
On 08/13/2012 01:19 PM, Sean Kelly wrote: Sounds like what's needed is a call counter, so if rt_init is called N times, rt_term must be called N times before the runtime really terminates. is it valid to call rt_init more than once?

Re: prevent multiple calls to rt_term

2012-08-13 Thread Ellery Newcomer
On 08/13/2012 03:37 PM, Sean Kelly wrote: On Aug 13, 2012, at 2:07 PM, Ellery Newcomer ellery-newco...@utulsa.edu wrote: On 08/13/2012 01:19 PM, Sean Kelly wrote: Sounds like what's needed is a call counter, so if rt_init is called N times, rt_term must be called N times before the runtime

template - aliasing a member function

2012-08-08 Thread Ellery Newcomer
say I have template T(alias fn) { } class Foo { int i(); void i(int); } alias T!(Foo.i) Biz; Is there a way to get a handle to both of the overloads of Foo.i inside T? Actually, all I really need for that is to get 'Foo.i' out of fn. mangleof looks promising..

Re: template - aliasing a member function

2012-08-08 Thread Ellery Newcomer
On 08/08/2012 04:21 PM, Ellery Newcomer wrote: mangleof looks promising.. .. or maybe not. wtf? template Z(string s) { pragma(msg, fn.mangleof 2: ~ s); } struct S(alias fn, string prop) { pragma(msg, fn.mangleof 1: ~ fn.mangleof); alias Z!(fn.mangleof) F; } class Foo

Re: sorting failed error

2012-07-30 Thread Ellery Newcomer
On 07/30/2012 05:36 AM, maarten van damme wrote: I have no idea what is wrong with my code and the error is not very informative. Does anyone have any idea as to what the problem could be? Congratulations, it looks like you've hit a compiler bug.

Re: Getting a range over a const Container

2012-07-20 Thread Ellery Newcomer
On 07/19/2012 06:09 PM, Ellery Newcomer wrote: On 07/19/2012 02:51 AM, Artur Skawina wrote: Range!Node opSlice() { return Range!Node(first); } Range!(const Node) opSlice() const { return Range!(const Node)(first); } it looks like you could almost merge these two into one

Re: Getting a range over a const Container

2012-07-19 Thread Ellery Newcomer
On 07/19/2012 02:51 AM, Artur Skawina wrote: Range!Node opSlice() { return Range!Node(first); } Range!(const Node) opSlice() const { return Range!(const Node)(first); } anyone mind cluing me in on why this is possible?

Re: Getting a range over a const Container

2012-07-19 Thread Ellery Newcomer
On 07/19/2012 06:18 PM, Ali Çehreli wrote: Now the output is different: non-const foo called on a const foo called on b Ali cool beans, thanks.

Re: using GC needs particular skills?

2012-07-15 Thread Ellery Newcomer
On 07/15/2012 09:01 AM, Alexandr Druzhinin wrote: 15.07.2012 22:56, Alexandr Druzhinin пишет: 15.07.2012 22:33, Alex Rønne Petersen пишет: test case: class A { } __gshared A a; void main(string[] args) { a = new A; } every time after finishing application I get

Re: aa.remove in a destructor

2012-06-28 Thread Ellery Newcomer
On 06/26/2012 12:41 PM, Steven Schveighoffer wrote: I want to red flag this code for another reason. You must *never* access GC-allocated references in a destructor, to do so will make the program crash randomly. The docs should be so assertive (not that I read them or anything). The

Re: aa.remove in a destructor

2012-06-26 Thread Ellery Newcomer
On 06/24/2012 01:56 PM, Ellery Newcomer wrote: Come to think of it, though, shouldn't the standard library provide an aa implementation that doesn't rely on the gc? ah, screw it, I'll just write my own.

Re: aa.remove in a destructor

2012-06-24 Thread Ellery Newcomer
On 06/24/2012 02:53 AM, Dmitry Olshansky wrote: I think no, as any with operation involving GC. For instance while you are removing elements table may decide to rehash itself and that means it may trigger allocation. okay, it looks like my [inherited] code is using aa's to map D objects to

aa.remove in a destructor

2012-06-23 Thread Ellery Newcomer
this code: class X{ string[string] s; this() { s[s] = S; } ~this() { s.remove(s); } } void main() { X x = new X(); } produces this: core.exception.InvalidMemoryOperationError because the aa is calling gc_free during a collection, apparently. Should I

compile time regex

2012-06-16 Thread Ellery Newcomer
There is a ctRegex; is there a compile time equivalent for match?

optlink

2012-05-13 Thread Ellery Newcomer
Hey, a while back I was messing around with some winapi calls in D, and I had occasion to want to link to crypt32.dll, but dmd doesn't seem to ship with a crypt32.lib. I tried downloading the platform sdk or whatever the thing is called, but, um... dmd ssl_client.d C:\Program

Re: Remarks on std.container

2012-03-08 Thread Ellery Newcomer
On 03/08/2012 03:21 AM, Matthias Walter wrote: Hi, I wanted to have a binary heap where I can update entries and restore the heap structure. shameless plug I totally built this functionality in to multi_index's red black tree, hash table, and heap indeces.

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

2012-03-07 Thread Ellery Newcomer
On 03/07/2012 12:23 AM, Ali Çehreli wrote: There are probably hundreds of discussions about that over the years on many different language newsgroups and forums. :) There is no clear winner: Both sides of the arguments seem to have good points. Ali know any good ones off the top of your

Re: Is empty array null?

2012-02-28 Thread Ellery Newcomer
On 02/28/2012 05:25 AM, Mikael Lindsten wrote: This means that I can doif (someString.length) { ... }without worrying about the null case (?). That's great! Correct

Re: Is empty array null?

2012-02-27 Thread Ellery Newcomer
On 02/27/2012 03:12 PM, Pedro Lacerda wrote: Ouch, I just found http://d.puremagic.com/issues/show_bug.cgi?id=3889 So how would I differ from an empty array and a null value? Pedro Lacerda If you know your type is an array, just use a.length to test if the array is empty. The concept of

Re: Is empty array null?

2012-02-27 Thread Ellery Newcomer
On 02/27/2012 03:17 PM, Justin Whear wrote: null makes sense to me. If the length is null, where can the ptr member point to other than null? In the case of empty array slices, ptr can point to anywhere. But then, empty array slices aren't null.

Re: SONAME and D

2012-02-24 Thread Ellery Newcomer
On 02/24/2012 06:27 AM, Jordi Sayol wrote: It compiles to 32-bit but fails for 64-bit, maybe due to compiled libphobos2 (64-bit) without -fPIC argument? What? -shared works with 32-bit? Holy crap, it does! this is awesome! maybe make a bug report for 64 bit?

deh_end

2012-02-24 Thread Ellery Newcomer
So I'm all trying out this hot new shared switch, and it works just dandy for -m32 when d has the main function. But now I want to be able to call my shared lib from C. my little shared lib, tup.d: import std.stdio; extern(C) void xyz(int i){ writeln(i); } compiled like so: dmd

fedora/ldc where are druntime headers?

2012-02-23 Thread Ellery Newcomer
looking for core.stuff I would have thought they would be in ldc-druntime-devel, but they don't seem to be, and I can't find them elsewhere

Re: fedora/ldc where are druntime headers?

2012-02-23 Thread Ellery Newcomer
On 02/23/2012 05:08 PM, bioinfornatics wrote: Le jeudi 23 février 2012 à 16:29 -0600, Ellery Newcomer a écrit : looking for core.stuff I would have thought they would be in ldc-druntime-devel, but they don't seem to be, and I can't find them elsewhere in ldc-druntime-devel see above command

Re: mixin template FAIL

2012-02-23 Thread Ellery Newcomer
Thanks for your reply. You're right about the statement. But I still think something's wrong. For example, even this program produces the errors: import std.stdio; mixin template helpMe() { writeln(Satisfying!); } does it do that if you replace the statement with a declaration? like this:

Re: fedora/ldc where are druntime headers?

2012-02-23 Thread Ellery Newcomer
grumph. is it not possible to fix the packages in repo? On 02/23/2012 05:17 PM, bioinfornatics wrote: get latest ldc build here: http://koji.fedoraproject.org/koji/buildinfo?buildID=299767 install it with yum install after dowloading these rpm

Re: mixin template FAIL

2012-02-21 Thread Ellery Newcomer
On 02/21/2012 01:53 PM, Ali Çehreli wrote: According to the docs, template mixins can have only declarations but helpMe above has a statement. http://dlang.org/template-mixin.html Ali come to think of it, I've occasionally wished for statement mixins. This would make a good enhancement

RedBlackTree.lowerBound

2012-02-19 Thread Ellery Newcomer
Is it just me or are lowerBound and upperBound really unintuitively named? From DDOC: c.lowerBound(v) Returns a range of all elements strictly less than v c.upperBound(v) Returns a range of all elements strictly greater than v. So c.lowerBound(v) will return a range for which v is the ..

Re: warning: size of symbol changed

2012-02-16 Thread Ellery Newcomer
On 02/16/2012 01:32 AM, Jacob Carlborg wrote: On 2012-02-16 03:35, Ellery Newcomer wrote: has anyone else gotten warnings of the nature /usr/bin/ld: Warning: size of symbol `{875charlongsymbol}' changed from 107 in multi_index.o to 99 in multi_index.o Sounds like you should do a clean build

warning: size of symbol changed

2012-02-15 Thread Ellery Newcomer
has anyone else gotten warnings of the nature /usr/bin/ld: Warning: size of symbol `{875charlongsymbol}' changed from 107 in multi_index.o to 99 in multi_index.o

Re: warning: size of symbol changed

2012-02-15 Thread Ellery Newcomer
On 02/15/2012 10:03 PM, Ali Çehreli wrote: On 02/15/2012 06:35 PM, Ellery Newcomer wrote: has anyone else gotten warnings of the nature /usr/bin/ld: Warning: size of symbol `{875charlongsymbol}' changed from 107 in multi_index.o to 99 in multi_index.o This can happen if there are two object

Re: dmd thrashes fedora

2012-02-12 Thread Ellery Newcomer
On 02/12/2012 08:34 AM, Timon Gehr wrote: It is a bug in your code: - ForEachIndex!(N+1, L).result; + ForEachIndex!(N+1, L[1..$]).result; The diagnostic DMD spits out is quite bad. Wow. In my defense, the original code is right; apparently dustmite did this to the reduced case. I know I

Re: shifting array slices

2012-02-11 Thread Ellery Newcomer
http://d.puremagic.com/issues/show_bug.cgi?id=7484 On 02/11/2012 12:09 PM, Ellery Newcomer wrote: I'm pretty sure this used to work: import std.algorithm; int[] ra; copy(ra[5 .. 10], ra[4 .. 9]); and would correctly shift the range [5 .. 10] down one (unlike ra[4 .. 9] = ra[5 .. 10], which

dmd thrashes fedora

2012-02-10 Thread Ellery Newcomer
when I run dmd -gc -oftopo topo.d multi_index.d replace.d on the contents of http://personal.utulsa.edu/~ellery-newcomer/bad.zip in fedora 16 x86_64 with dmd 2.057 64 bit dmd starts thrashing like there is no tomorrow and generally locks up my entire system. Can anyone confirm

toString multiple overrides

2012-02-10 Thread Ellery Newcomer
dmd 2.057 Two mixin templates, each define toString, mix them in to your class and .. Error: function test.X.T2!().toString multiple overrides of same function So this behavior is new, but is it sensical? Sample code: mixin template T1(){ string toString(){ return 1; } } mixin

Re: for loop

2012-01-23 Thread Ellery Newcomer
On 01/22/2012 11:37 AM, Zachary Lund wrote: This is an ugly solution (and I'm not 100% sure it's valid D) but: /+/ void main() { { short y = 0; int x = 0; for (; x 10; ++x, ++y) { } } } /+/ raise you. void main(){ for ({int

Re: shared lib

2011-11-15 Thread Ellery Newcomer
On 11/15/2011 01:19 AM, Jacob Carlborg wrote: On 2011-11-14 19:05, Ellery Newcomer wrote: core.runtime.Runtime.initialize cool Not sure if that will initialize everything properly. Have a look in rt.dmain2.main and make sure you do that same initialize the runtime. yep, found that file

Re: shared lib

2011-11-14 Thread Ellery Newcomer
On 11/14/2011 10:31 AM, Jerry wrote: The error looks like phobos wasn't build with position-independent code. Jerry you know, I think you're right. I even wrote out the names of all those *.a files when I was building a gdc rpm. *slaps head* well, it doesn't matter now. I've gotten ldc to

shared lib

2011-11-10 Thread Ellery Newcomer
trying to build a .so file (actually, trying to resuscitate pyd) with gdc. celerid is spitting out gdc -fPIC -nostartfiles -shared -fdebug {lots of object files plus some link directives} which is spitting out /usr/bin/ld: /usr/lib64/libgphobos2.a(object_.o): relocation R_X86_64_32S against

odd use of preprocessor

2011-11-06 Thread Ellery Newcomer
poking about in elfutils headers, I've come across the following idiom several times /* Error values. */ enum { DW_TAG_invalid = 0 #define DW_TAG_invalid DW_TAG_invalid }; anyone know if anything strange is going on here that would prevent trivial conversion to d?

Re: odd use of preprocessor

2011-11-06 Thread Ellery Newcomer
On 11/06/2011 01:50 PM, Alex Rønne Petersen wrote: On 06-11-2011 20:43, Ellery Newcomer wrote: poking about in elfutils headers, I've come across the following idiom several times /* Error values. */ enum { DW_TAG_invalid = 0 #define DW_TAG_invalid DW_TAG_invalid

Re: int C function

2011-10-01 Thread Ellery Newcomer
On 10/01/2011 08:33 AM, Andrej Mitrovic wrote: On 10/1/11, Ellery Newcomer ellery-newco...@utulsa.edu wrote: On 09/30/2011 08:20 PM, Andrej Mitrovic wrote: I think this is a side-effect of the new function pointer fixes, where you now can't implicitly convert an extern(C) function to an extern

int C function

2011-09-30 Thread Ellery Newcomer
weird error. anyone know what's going on? [ellery@localhost d]$ cat test.d extern(C) int puts(const char *s); class X{ @property void tt(int function(const char *) xz){ } } void main(){ X x = new X(); x.tt = puts; } [ellery@localhost d]$ dmd test test.d(8): Error: function

Re: int C function

2011-09-30 Thread Ellery Newcomer
On 09/30/2011 08:20 PM, Andrej Mitrovic wrote: I think this is a side-effect of the new function pointer fixes, where you now can't implicitly convert an extern(C) function to an extern(D) function by accident (and that's a good thing). But the problem is, you can't define a function with a

Re: int C function

2011-09-30 Thread Ellery Newcomer
On 09/30/2011 08:20 PM, Andrej Mitrovic wrote: I think this is a side-effect of the new function pointer fixes, where you now can't implicitly convert an extern(C) function to an extern(D) function by accident (and that's a good thing). But the problem is, you can't define a function with a

Re: Why is std.string.format a c-style variadic function?

2011-09-26 Thread Ellery Newcomer
On 09/26/2011 07:42 AM, Andrej Mitrovic wrote: On 9/26/11, Jacob Carlborg d...@me.com wrote: std.string.format is using a D-style variadic parameter list. The compiler disagrees with you: D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\string.d(2432): Error: function std.string.format

Re: How do formally you call the 'in' operator?

2011-09-24 Thread Ellery Newcomer
On 09/24/2011 01:18 PM, Andrej Mitrovic wrote: Information about overloading opIn and opIn_r is missing from the docs, so I'm writing that section. But I don't know what is the formal name of this operator so I can put it in the title. Maybe I should just name the title Overloading the In

Re: Why this simple binaryHeap program does not compile?

2011-09-22 Thread Ellery Newcomer
On 09/22/2011 06:10 AM, Cheng Wei wrote: Is this a bug or I use the binary heap wrongly? Thanks a lot! Looks like a bug in Array. emplace doesn't accept a pointer to a chunk for class types. Report that puppy!

Re: attribute decl in version decl

2011-09-19 Thread Ellery Newcomer
On 09/18/2011 01:02 PM, Timon Gehr wrote: If you are asking, if the D compiler is wrong here: No, it is by design, you can check with the D grammar. Nah, just confirming that failure to apply the externs is a bug.

Re: attribute decl in version decl

2011-09-19 Thread Ellery Newcomer
On 09/18/2011 04:09 PM, Trass3r wrote: Am 18.09.2011, 18:55 Uhr, schrieb Ellery Newcomer ellery-newco...@utulsa.edu: Just came across some old D code that does this: version(linux){ extern(C): } Hundreds of OpenGL decls in dmd 2.055, the extern(C) is not being applied

Re: attribute decl in version decl

2011-09-19 Thread Ellery Newcomer
On 09/18/2011 11:04 PM, Daniel Murphy wrote: Ellery Newcomer ellery-newco...@utulsa.edu wrote in message news:j557r6$vgt$1...@digitalmars.com... Just came across some old D code that does this: version(linux){ extern(C): } Are the prototypes extern(Windows) when not on linux, by any

Re: attribute decl in version decl

2011-09-19 Thread Ellery Newcomer
On 09/19/2011 08:59 AM, Timon Gehr wrote: You could use the C preprocessor ;). Or this, that does the same thing: version(V1) private enum _v1=true; else private enum _v1=false; mixin((_v1?extern(System)::extern(C):)~q{ // all declarations that should be affected. }); code golf or

to invalidate a range

2011-08-12 Thread Ellery Newcomer
in std.container, the stable* container functions advocate that they do not invalidate the ranges of their containers. What does it mean to invalidate a range? my assumption is it means causing e.g. front or popFront to fail when empty says they should succeed or vice versa.

Re: to invalidate a range

2011-08-12 Thread Ellery Newcomer
On 08/12/2011 03:13 PM, bearophile wrote: Ellery Newcomer: in std.container, the stable* container functions advocate that they do not invalidate the ranges of their containers. What does it mean to invalidate a range? Generally modifying a collection while you iterate on it causes troubles

Re: to invalidate a range

2011-08-12 Thread Ellery Newcomer
On 08/12/2011 03:29 PM, Steven Schveighoffer wrote: On Fri, 12 Aug 2011 15:54:53 -0400, Ellery Newcomer ellery-newco...@utulsa.edu wrote: in std.container, the stable* container functions advocate that they do not invalidate the ranges of their containers. What does it mean to invalidate

Re: to invalidate a range

2011-08-12 Thread Ellery Newcomer
On 08/12/2011 03:54 PM, Jonathan M Davis wrote: In the case of container that uses nodes - such as a linked list - because you can add and remove elements without affecting other elements, iterators and ranges don't tend to get invalidated as easily. As long as you don't remove the element (or

Re: to invalidate a range

2011-08-12 Thread Ellery Newcomer
On 08/12/2011 05:51 PM, Jonathan M Davis wrote: An implementation can guarantee it as long as your range doesn't directly point to an element being removed (i.e. as long as the element isn't on the ends - or maybe one past the end, depending on the implementation). But _no_ container can

Re: to invalidate a range

2011-08-12 Thread Ellery Newcomer
On 08/12/2011 06:34 PM, Jonathan M Davis wrote: Forgive my being dense, but where is this 'as long as' coming from? If your range only points to ends in e.g. a linked list, how is it supposed to retrieve elements in the middle? I'm having a hard time visualizing a range over a node based

Re: unsigned int in for loops

2011-02-04 Thread Ellery Newcomer
I think this was the impetus for foreach_reverse, or at least it is one place where it is pretty handy. Don't remember what all there is in D1, but in D2 you could do something like foreach_reverse(i; 0u .. 10u){ // iterates over 9,8,7 .. 1,0 } for more complex iterations, I suppose you're

Re: unsigned int in for loops

2011-02-04 Thread Ellery Newcomer
On 02/04/2011 02:31 PM, Jesse Phillips wrote: Ellery Newcomer Wrote: I think this was the impetus for foreach_reverse, or at least it is one place where it is pretty handy. Don't remember what all there is in D1, but in D2 you could do something like foreach_reverse(i; 0u .. 10u){ // iterates

Re: common types + type modifiers

2011-01-30 Thread Ellery Newcomer
On 01/30/2011 09:47 AM, Michel Fortin wrote: On 2011-01-29 20:09:11 -0500, Ellery Newcomer ellery-newco...@utulsa.edu said: trying to wrap my head around shared,const,immutable (not inout yet, though someday I'll need to figure out what it's supposed to do) Currently, dmd doesn't exhibit

Re: pragma(msg,

2011-01-30 Thread Ellery Newcomer
On 01/30/2011 03:47 PM, Philippe Sigaud wrote: On Sun, Jan 30, 2011 at 19:15, Ellery Newcomer ellery-newco...@utulsa.edu wrote: doh. when I did something like enum string s = tct!(int,int); it just took it and didn't complain that it didn't know the value at compile time. I think

pragma(msg,

2011-01-29 Thread Ellery Newcomer
code: template tct(T1,T2){ string tct = T1.stringof ~ ~ T2.stringof ~ typeof(true?T1.init:T2.init).stringof; } pragma(msg, tct!(shared(const(int))*, const(int*))); result: tct why?

common types + type modifiers

2011-01-29 Thread Ellery Newcomer
trying to wrap my head around shared,const,immutable (not inout yet, though someday I'll need to figure out what it's supposed to do) Currently, dmd doesn't exhibit a lot of consistency wrt the above, so bear with me as I question every ing thing it does. my [erroneous?] understanding of

hex strings

2011-01-26 Thread Ellery Newcomer
just out of curiosity, does anyone use these and actually mean them to be strings? It seems like I'm invariably writing cast(ubyte[]) x...

Re: hex strings

2011-01-26 Thread Ellery Newcomer
On 01/26/2011 01:35 PM, Jonathan M Davis wrote: On Wednesday, January 26, 2011 11:29:59 bearophile wrote: Jonathan M Davis: That's legal? They are a part of D language, search for Hex Strings here: http://www.digitalmars.com/d/2.0/lex.html It always seems like there's at least one more

Re: hex strings

2011-01-26 Thread Ellery Newcomer
On 01/26/2011 02:16 PM, Simen kjaeraas wrote: Ellery Newcomer ellery-newco...@utulsa.edu wrote: just out of curiosity, does anyone use these and actually mean them to be strings? It seems like I'm invariably writing cast(ubyte[]) x... Never used them, tbh. But shouldn't that be cast(ubyte

Re: hex strings

2011-01-26 Thread Ellery Newcomer
On 01/26/2011 05:57 PM, spir wrote: On 01/26/2011 07:25 PM, Ellery Newcomer wrote: just out of curiosity, does anyone use these and actually mean them to be strings? It seems like I'm invariably writing cast(ubyte[]) x... Super-nice for universal text. Anything you can't type in because

Re: concatenation

2011-01-26 Thread Ellery Newcomer
On 01/24/2011 05:22 PM, Robert Clipsham wrote: On 24/01/11 23:09, Ellery Newcomer wrote: in the following: void main(){ char[] x; string s; string y; y = s ~ x; } tok.d(5): Error: cannot implicitly convert expression (cast(const(char)[])s ~ x) of type char[] to string why should typeof(s

concatenation

2011-01-24 Thread Ellery Newcomer
in the following: void main(){ char[] x; string s; string y; y = s ~ x; } tok.d(5): Error: cannot implicitly convert expression (cast(const(char)[])s ~ x) of type char[] to string why should typeof(s ~ x) == char[] ?

Re: Using D libs in C

2011-01-16 Thread Ellery Newcomer
On 01/16/2011 03:34 PM, Andrej Mitrovic wrote: The problem (on Windows), is that the static lib is in the OMF format, and modern tools like VC or MinGW won't be able to read those, because they use COFF instead. So you would have to convert from OMF to COFF. But on Linux I think DMD uses the

Re: Using D libs in C

2011-01-16 Thread Ellery Newcomer
On 01/16/2011 05:04 PM, Ellery Newcomer wrote: On 01/16/2011 03:34 PM, Andrej Mitrovic wrote: The problem (on Windows), is that the static lib is in the OMF format, and modern tools like VC or MinGW won't be able to read those, because they use COFF instead. So you would have to convert from

druntime

2011-01-08 Thread Ellery Newcomer
where did libdruntime.a go in dmd.2.051.zip:/linux/lib ?

Re: druntime

2011-01-08 Thread Ellery Newcomer
On 01/08/2011 09:02 PM, Jonathan M Davis wrote: On Saturday 08 January 2011 13:32:19 Ellery Newcomer wrote: where did libdruntime.a go in dmd.2.051.zip:/linux/lib ? I think that it's included inside of libphobos.a now, and has been for a few releases. The libraries are still separate, and you

auto declarations

2011-01-07 Thread Ellery Newcomer
auto a = 1, b = null; int a = 1, *b = null; The first is accepted by dmd, and it should result in typeof(a) == int and typeof(b) == void*. It is somewhat contradictory to the error message resulting from the second: multiple declarations must have the same type, not int and int* I am

Re: Why does the example on page 8 of TDPL work without importing std.algorithm for splitter?

2011-01-03 Thread Ellery Newcomer
If you're importing some other phobos module, I would guess an instance of this bug: http://d.puremagic.com/issues/show_bug.cgi?id=314 On 01/03/2011 10:56 AM, Bryce Watkins wrote: However when I use splitter in my code it works without having imported std.algorithm. Thanks, Bryce.

<    1   2   3   4   >