Re: runtime type and that bizarre is()

2010-11-14 Thread BCS
Hello Jonathan, On Sunday 14 November 2010 03:45:12 spir wrote: Hello, Is there a way to check the runtime type of an element? Meaning, for instance, process differently according to the actual type in a hierarchy? class C {} class C1 : C {int i;} bool checkTypeC1 (C c) { return

Re: Switch constants

2010-11-14 Thread BCS
Hello bearophile, In a not-ranged cases body, like in the program below (that doesn't compile), the switch variable is a compile-time constant, so why doesn't the compile see x as constant there? template Foo(uint x) { static if (x = 1) enum Foo = 1; else enum Foo = x * Foo!(x - 1); } int

Re: atomicOp problem

2010-10-21 Thread BCS
Benjamin Thaut c...@benjamin-thaut.de wrote: I recently read the book the D programming language and wanted to try out a few of the multithreaded examples pointed out in this book. I tried to write a version of the bank account example using the atomicOp from core.atomic. But when I compile

Re: lvalue method

2010-10-13 Thread BCS
Hello Benjamin, Am 08.10.2010 11:13, schrieb Lars T. Kyllingstad: On Fri, 08 Oct 2010 09:33:22 +0200, Benjamin Thaut wrote: Hi, I'm writing a vec4 math struct and I have a method of which the return value has to be a lvalue so I wonder which is the correct way to do this: vec4 Normalize()

building phobse with a non standard dmd?

2010-10-04 Thread BCS
GAH I HATE MAKE!! Has anyone built libphobse.a and friends with a dmd other than the default? I can use DMD=/path/to/dmd in the first level make and I can do the same plus what the make file adds for the recursive call but when I start needing to do it yet again for the call into

Re: Where have all the sources gone?

2010-09-26 Thread BCS
Hello Jacob, On 2010-09-26 03:43, BCS wrote: Hello Jacob, On 2010-09-25 03:08, BCS wrote: I've found the phobos source: http://www.dsource.org/projects/phobos/browser/trunk/phobos The DMD source: http://www.dsource.org/projects/dmd/browser/trunk/ and this seems to be the runtime

Re: Where have all the sources gone?

2010-09-25 Thread BCS
Hello Jacob, On 2010-09-25 03:08, BCS wrote: I've found the phobos source: http://www.dsource.org/projects/phobos/browser/trunk/phobos The DMD source: http://www.dsource.org/projects/dmd/browser/trunk/ and this seems to be the runtime: http://www.dsource.org/projects/druntime/browser

Where have all the sources gone?

2010-09-24 Thread BCS
I've found the phobos source: http://www.dsource.org/projects/phobos/browser/trunk/phobos The DMD source: http://www.dsource.org/projects/dmd/browser/trunk/ and this seems to be the runtime: http://www.dsource.org/projects/druntime/browser/trunk/ But I can't seem to even find object.d or

Re: Translation of C function pointer.

2010-09-16 Thread BCS
Hello Steven, // note you can't use void as a parameter type in D void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(/*void*/); pragma(msg, typeof(xDlSym).stringof); outputs: void function() function(sqlite3_vfs*, void*, const const(char*) zSymbol) D, now with C type un-garbleing!

Re: Translation of C function pointer.

2010-09-16 Thread BCS
Hello Steven, On Thu, 16 Sep 2010 10:06:24 -0400, BCS n...@anon.com wrote: Hello Steven, // note you can't use void as a parameter type in D void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(/*void*/); pragma(msg, typeof(xDlSym).stringof); outputs: void function() function

Re: Am I doing this right? (File byChunk)

2010-09-12 Thread BCS
Hello Andrej, Here's a little snippet of code that interfaces with Scintilla (it works btw.): File file = File(test.txt, r); foreach (ubyte[] buf; file.byChunk(4096)) { sendEditor(SCI_ADDTEXT, buf.length, (cast(char[])buf).idup); } The cast looks ugly, but I *have* to send a copy. What do

Re: name of map file

2010-09-12 Thread BCS
Hello Andrej, Yeah but using -of creates an executable in the directory I provide. RDMD is supossed to be used with hiding the executable in a temp dir, afaik. So it's hashing at play, ok. Just wanted to know why. Personally I'd like RDMD to hide the map and deps files as well, I don't know

Re: void[] vs byte[]

2010-08-28 Thread BCS
Hello Yao G., I'm here with another n00b question: When dealing with big buffers (or files), which is better to use as storage? void[] or byte[]? If the data may contain pointers into the heap, use void[] if it will not use byte[]. byte[] is raw data, void[] is anything at all. What

Re: template subclass as template parameter

2010-08-11 Thread BCS
Hello Ivo, class C(T, U : A!(T)) { ... } And I'm trying to do this void main() { C!(double, B!(double)) var; } but dmd complains: Error: template instance C!(double,B) does not match template declaration C(T,U : A!(T)) The way you have it is asking for an exact match. I would have to look

Re: What is the term for a function that can be CTFEed?

2010-08-10 Thread BCS
Hello Jonathan, On Monday 09 August 2010 21:18:42 BCS wrote: We have pure functions, member functions, static functions and global functions; but what kind of function can always be used with CTFE? Haven't we typical called them CTFE or CTFEable functions? I've seen the first used, even

Re: Casting away const

2010-08-09 Thread BCS
Hello Steven, On Sun, 08 Aug 2010 17:56:25 -0400, simendsjo simen.end...@pandavre.com wrote: I'm totally new to the const/immutable thing, so this might be a naive question.. The spec says: modification after casting away const = undefined behavior I thought it was you're on your own, not

Re: Casting away const

2010-08-09 Thread BCS
Hello Steven, On Mon, 09 Aug 2010 10:11:39 -0400, Don nos...@nospam.com wrote: Steven Schveighoffer wrote: On Sun, 08 Aug 2010 17:56:25 -0400, simendsjo simen.end...@pandavre.com wrote: I'm totally new to the const/immutable thing, so this might be a naive question.. The spec says:

Re: Casting away const

2010-08-09 Thread BCS
Hello Steven, On Mon, 09 Aug 2010 09:57:47 -0400, bearophile bearophileh...@lycos.com wrote: Steven Schveighoffer: I thought it was you're on your own, not undefined behavior. The former implies there is some right way to do this if you know more about the data than the compiler, the

Re: Casting away const

2010-08-09 Thread BCS
Hello Steven, On Mon, 09 Aug 2010 10:37:14 -0400, BCS n...@anon.com wrote: Hello Steven, On Mon, 09 Aug 2010 10:11:39 -0400, Don nos...@nospam.com wrote: Steven Schveighoffer wrote: On Sun, 08 Aug 2010 17:56:25 -0400, simendsjo simen.end...@pandavre.com wrote: I'm totally new

Re: Casting away const

2010-08-09 Thread BCS
Hello Steven, On Mon, 09 Aug 2010 10:24:56 -0400, BCS n...@anon.com wrote: Hello Steven, On Sun, 08 Aug 2010 17:56:25 -0400, simendsjo simen.end...@pandavre.com wrote: I'm totally new to the const/immutable thing, so this might be a naive question.. The spec says: modification after

Re: Casting away const

2010-08-09 Thread BCS
Hello Steven, On Mon, 09 Aug 2010 10:53:48 -0400, BCS n...@anon.com wrote: C's api can be modified at declaration. It has no mangling, so you can type it how it should be (if C had const). For example: extern(C) int strlen(const(char)* str); I find that much more pleasant than having

What is the term for a function that can be CTFEed?

2010-08-09 Thread BCS
We have pure functions, member functions, static functions and global functions; but what kind of function can always be used with CTFE? -- ... IXOYE

Re: What is the term for a function that can be CTFEed?

2010-08-09 Thread BCS
Hello BCS, We have pure functions, member functions, static functions and global functions; but what kind of function can always be used with CTFE? Compile Time Evaluable Function = CTEF? (sounds like CDEF; so testing many minor variant of one you get AB CTEF testing :b

Re: What on earth is a ref function?

2010-08-08 Thread BCS
Hello simendsjo, The spec is very short here, and the example doesn't give me much.. // I thought allows functinos to return by reference meant it could return local variables.. ref int* ptr() { auto p = new int; *p = 12; return p; // Error: escaping local variable } // So whats the difference

Re: Casting away const

2010-08-08 Thread BCS
Hello simendsjo, I'm totally new to the const/immutable thing, so this might be a naive question.. The spec says: modification after casting away const = undefined behavior // ptr to const int const(int)* p; int* q = cast(int*)p; *q = 3; // undefined behavior But why would you want to cast

Re: Is is the same as ptr == ptr for arrays?

2010-08-07 Thread BCS
Hello Simen, simendsjo simen.end...@pandavre.com wrote: Ok, thanks. Does this mean this equivalent then? int[] a = [1,2,3]; int[] b = a[0..1]; assert(a !is b); assert(a.ptr == b.ptr a.length == b.length); Well, no. both asserts will fail (a.length == 3 != b.length == 1) But what you

Re: Static arrays passed by value..?

2010-08-07 Thread BCS
Hello simendsjo, The spec for array says: Static arrays are value types. Unlike in C and D version 1, static arrays are passed to functions by value. Static arrays can also be returned by functions. I don't get the static arrays are passed to functions by value part. Here I am passing in a

Re: Reporting unsupported template instantiation

2010-08-04 Thread BCS
Hello Kagamin, http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmar s.Darticle_id=114518 Is there a way to report a custom error message for unsupported template instantiations? template Foo(T) { static assert(Chcek!(T), message); ... } template Bar(T) if (is( T ==

Re: Initializing static arrays without specifying size

2010-08-02 Thread BCS
Hello bearophile, Philippe Sigaud: Would a template-based solution be OK? import std.stdio, std.traits; CommonType!T[T.length] staticArray(T...)(T vals) if ((T.length 0) is(CommonType!T)) { return [vals]; } That's one solution, but code like that is most useful when your arrays liters

Re: Newbie questions on memory allocation

2010-07-24 Thread BCS
Hello Deokjae, Hi there, I have some questions on the following code. import std.stdio; struct S { int x; } void main() { int[3] a = new int[3];//A S* b = new S();//B delete b;//C } What's the meaning of the line A? Is the array allocated on heap? or stack? IITC new give you something on

Re: [D1] capitalize cannot be interpreted at CT

2010-07-22 Thread BCS
Hello Don, Ellery Newcomer wrote: On 07/21/2010 09:09 PM, strtr wrote: Could somebody please explain this error to me. evidently ctfe can't eat foreach(i, dchar d; s){ } Bleach. Make sure it's in bugzilla. CTFE currently doesn't work on *any* functions which are implemented in

Re: associative arrays: to sort or not to sort?

2010-07-21 Thread BCS
Hello Mario, Unless JSON requiers that the keys be in some order, No, JSON does not require the names of an object to be in alphabetical order. the correct solution is to make the check order independent. For example: string s = CallReturningJSON(); s = replace(s,`a:23.54`, `X`); s =

Re: associative arrays: to sort or not to sort?

2010-07-21 Thread BCS
Hello Mario, But then, JSON has a jew more unspecified gaps like whitespace can be inserted between any pair of tokens. That can be dealt with by just being consistent. Shall we rely on the fact that the implementation currently does not insert whitespace between tokens? On the output

Re: associative arrays: to sort or not to sort?

2010-07-18 Thread BCS
Hello Mario, That is, shall we produce canonical JSON text at the price of efficiency. Or, shall the perfect implementation of JSON objects as associative arrays be dropped? Or, what else? Unless JSON requiers that the keys be in some order, the correct solution is to make the check

Re: linker error

2010-07-12 Thread BCS
Hello j, hi, can anybody tell me please why the linker keeps bringing up this error message? i am using the latest dmd 2. thank you OPTLINK (R) for Win32 Release 8.00.2 Copyright (C) Digital Mars 1989-2009 All rights reserved. http://www.digitalmars.com/ctg/optlink.html

Re: Multi dimensional array question.

2010-07-11 Thread BCS
Hello dcoder, Hello. I'm wondering why in D if you declare a fixed multi dimensional array, you have to reverse the index order to access an element. When declaring an array, the base type is getting wrapped. When using an array, the base types get unwrapped. Because both forms place the

Re: Grokking concurrency, message passing and Co

2010-07-11 Thread BCS
Hello div0, The rule of thumb is don't bother spawning more threads than you have cpus. You're just wasting resources mostly. You REALLY don't want more threads trying to run than you have cores. Threads in a wait state, are less of an issue, but they still use up resources. -- ... IXOYE

Re: Grokking concurrency, message passing and Co

2010-07-11 Thread BCS
Hello div0, On 11/07/2010 20:00, BCS wrote: Hello div0, The rule of thumb is don't bother spawning more threads than you have cpus. You're just wasting resources mostly. You REALLY don't want more threads trying to run than you have cores. Threads in a wait state, are less of an issue

Re: Grokking concurrency, message passing and Co

2010-07-11 Thread BCS
Hello div0, On 11/07/2010 21:43, BCS wrote: In what way? Sometimes it just makes your program design easier if you fork a process / spawn a thread; than trying to manage a thread pool and allocating work to a fixed number of threads. Programmer time is more expensive than cpu time

Re: const and immutable

2010-07-06 Thread BCS
Hello Tim, I think I understand the difference between const and immuable when considering references and pointers, but how exactly is const different from immutable in: [...] const(int) somefunc(); versus immutable(int) somefunc(); BTW both of those are pointless. The following works:

Re: Templates with strings

2010-07-03 Thread BCS
Hello Mike, I'm trying to compile the following file. Can somebody explain to me how I can rewrite it so that I don't get Error: non-constant expression? All I'm trying to do is create, using templates, a string of all characters between two given characters: 1) where did you get that error?

Re: Purity of alloca()

2010-07-02 Thread BCS
Hello bearophile, Is alloca() pure? Given the same input alloca() generally returns different pointers, so it's not a pure function. But the same is true for the ptr field when you allocate an array on the heap. And the memory allocated by alloca() never escapes the function, so it looks

Re: How do I make an extern function?

2010-06-29 Thread BCS
Hello Simen, BCS n...@anon.com wrote: You can resolve this by having a a.di file with the extern foo(); in it (DMD has a flag to generate such a file for you). OTOH without knowing what you are doing, I can't tell if this is the correct solution. I'm trying to create a framework

Re: Why doesn't this work in D2?

2010-06-28 Thread BCS
Hello Jacob, On 2010-06-28 02:28, BCS wrote: One solution would be to have templates strip off const/immutable from the top level of args. [...] This solution would match the proposal that popped up a while ago to allow value assignment from const/immutable to mutable. I don't think I

Re: auto functions not authorized inside main?

2010-06-28 Thread BCS
Hello Rory, On Sun, 27 Jun 2010 17:17:25 +0200, Philippe Sigaud philippe.sig...@gmail.com wrote: void main() { auto fun(string s) { return s;} // this does not compile } Hope this isn't a stupid question, but how would you access this function if it did work? Would it be fun(asdf)? Is this

Re: How do I make an extern function?

2010-06-28 Thread BCS
Hello Simen, module a; extern void foo( ); void bar( ) { foo( ); } module b; import std.stdio; void foo( ) { writeln( Hi! ); } The above does not work (Error 42: Symbol Undefined _D1a3fooFZv). Adding extern to foo in module b

Re: Grokking std.container and Ranges

2010-06-28 Thread BCS
Hello Mike, I want to do the following: foreach(obj; list) { if(obj.pleaseKillMe) somehow_remove_the_object_from_the_list(); } That isn't legal for normal arrays or AAs. IIRC the docs even say that you can't change what a foreach is iterating over during the foreach. I think you will have

Re: Best way to test predicate against a range

2010-06-27 Thread BCS
Hello Jonathan, For example, there are two functions that I'd like to be have: all() and any(). That is, I want a function which checks a predicate against a range and returns whether all elements in that range satisfy the predicate, and I want a function that checks a predicate against a range

Re: Why doesn't this work in D2?

2010-06-27 Thread BCS
Hello Jacob, That's annoying, specially since char is a value type. I would preferably have a solution for both D1 and D2. Can I use a template to cast/alias away the immutable part? One solution would be to have templates strip off const/immutable from the top level of args. void F1(T)(T

Re: undefined identifier with scope statement?

2010-06-13 Thread BCS
Hello Trass3r, import std.stdio; void main() { scope(exit) writeln(res); auto res = 0; } This compiles, but using failure or success in the scope guard statement gives undefined identifier res. Is this intended? If yes, why? I'm going to guess that the given case is an accepts-invalid bug

Re: using std.process

2010-06-11 Thread BCS
Hello Graham, On Fri, 11 Jun 2010 19:09:04 +, Philippe Sigaud wrote: OK, this is a real newbie question: How can I use std.process? when I do: import std.process; void main() { execvp(mkdir, [test]); } nothing happens. What am I doing wrong? I'm on Vista there, didn't try the

Re: noob Q: declaring string variables

2010-05-30 Thread BCS
Hello Duke, On Sun, 30 May 2010, Philippe Sigaud wrote: On Sun, May 30, 2010 at 08:54, Simen kjaeraas simen.kja...@gmail.comwrote: Duke Normandin dukeofp...@ml1.net wrote: [sidebar] Why is every D tutorial I've touched upon so far, been frigged up? This is NOT good advocacy, people! Bad

Re: Small opCall problem

2010-05-30 Thread BCS
Hello bearophile, struct Foo(T) { this(T x) {} void opCall(U)(U y) {} } void main() { auto foo = Foo!int(1); foo(1.5); } FWIW, The struct being a template is extraneous. temp.d(7): Error: constructor temp.Foo!(int).Foo.this (int x) is not callable using argument types (double) The lookup

Re: noob Q: declaring string variables

2010-05-29 Thread BCS
Hello Duke, char[] password = sesame; IIRC you are using D2 and that only work for D1, for D2 I think you need to do: string password = sesame; This has something to do with the const system. I do know there is no way to safely modify a char[] set from a string literal so D2 forcing you

Re: CreateThread?

2010-05-28 Thread BCS
Hello Pavel, I create win32 application. (use dmd 2.046) Exist object Thread in std.thread. Object Thread gives support for garbage collector, but I want to use the function CreateThread. Can I create threads with this function? You can call it (you can call any C function). It should give

Re: Handy templates

2010-05-28 Thread BCS
Hello Don, Philippe Sigaud wrote: On Thu, May 27, 2010 at 01:00, Simen kjaeraas simen.kja...@gmail.com mailto:simen.kja...@gmail.com wrote: Here's a collection of templates I have created and use often. Some of these may be fit for inclusion in Phobos, others maybe not as much. Please

Re: noob Q: array out-of-range

2010-05-28 Thread BCS
Hello Simen, Duke Normandin dukeofp...@ml1.net wrote: So these two paragraphs in the tutorial are flat out wrong? Absolutely. Any idea who owns it so it can get changed? For that matter, who added the link? Being paranoid for the moment (it can be fun sometimes :) that blurb is so

Re: Loop optimization

2010-05-17 Thread BCS
Hello Don, The most glaring limitation of the FP optimiser is that it seems to never keep values in the FP stack. So that it will often do: FSTP x FLD x instead of FST x Fixing this would probably give a speedup of ~20% on almost all FP code, and would unlock the path to further optimisation.

Re: if(bool = x) does not give a boolean result

2010-05-08 Thread BCS
Hello Steven, No. I meant bool = bool. I'm not comparing two bools, I'm assigning to a bool, and then using if on the result. At best, this is a bogus error message. More often than not (or so the thinking goes), that isn't the case and the programmer in fact did want ==. Also, you

Re: newbie: Circular references across modules

2010-04-30 Thread BCS
Hello Ellery, as long as you don't need any static constructors or destructors in either a or b. It's a side issue but: static constructors + cyclic imports == pain -- ... IXOYE

Re: Newsgroups, off-topic

2010-04-18 Thread BCS
Hello Joseph, I can also see the desire to have a backend that is fully under the control of the main developers. There is also the point that if Walter never looks at the source for another compiler, it is nearly impossible for him to be sued for stealing from them. -- ... IXOYE

Re: metaprogramming question

2010-04-18 Thread BCS
Hello Justin Spahr-Summers, On Mon, 19 Apr 2010 00:12:28 + (UTC), Graham Fawcett fawc...@uwindsor.ca wrote: Hi folks, I'd like to wrap a family of C functions that look like this: gboolean fooXXX(arg1, ..., argN, GError** err) Their signatures and arities vary, but they all have a

Re: metaprogramming question

2010-04-18 Thread BCS
Hello Philippe, Of course, it'd be nice to check the EL at CT to see if they correspond to func parameters types. The call inside check will coever that for you as long as you don't mind getting the error in an odd place. -- ... IXOYE

Re: Class-related queries [was: Re: 'Undefined reference' linking errors]

2010-04-09 Thread BCS
Hello Joseph, To be sure I understand -- is there anything wrong with writing scope auto f = new Foo(i) BTW, the following might work: scope f = new Foo(i); -- ... IXOYE

Re: string to real conversion losing data

2010-04-08 Thread BCS
Hello bearophile, writefln(%.5f\n, tot); // 17744.06000 Never trust your output function :) (e.i. always check to see if it's doing what you think it is.) Back in the bad old days, a guy I knew spent a while debugging a problem that turned out to be that he was loading data as float but

Re: Comparing Two Type Tuples

2010-04-06 Thread BCS
Hello Justin Spahr-Summers, On Mon, 5 Apr 2010 15:47:10 + (UTC), BCS n...@anon.com wrote: I dind't know it worked? It seemed to when I tested the snippet that I sent, but it might've just been luck of the draw, and in reality fail silently on certain edge cases. I'm really not sure

Re: how to get timestamp in compile-time?

2010-03-23 Thread BCS
Hello Simen, On Tue, 23 Mar 2010 08:35:54 +0100, Zólyomi Istvan istvan.zoly...@gmail.com wrote: Hi, recently I've been experimenting with metaprogramming in D. I've been trying to create a simple compiler benchmark that can be used like the following oversimplified code: const time

Re: D1: Overloading across modules

2010-03-23 Thread BCS
Hello Nick, Is overloading across modules not allowed? Is overloading on two different enum types not allowed? Is it a DMD bug? Or does this all work fine and I probably just have some other problem elsewhere? IIRC, this is done so that importing a module will never alter what function a

Re: What do you use opDispatch for?

2010-03-21 Thread BCS
Hello Philippe, OK, I know opDispatch just appeared in DMD, but I remember a *huge* thread on it, where people were jumping up and down waiting for it. Me, I have no wonderful idea, though I feel some potential in it. The only interesting use I found for now is making a class/struct

How to chain constructor args to a template memeber

2010-03-11 Thread BCS
Using D2, I have a template class that looks something like this: class C(T) { T t; } (For simplicity, assume T is required to be a struct of some kind.) I want to have a constructor that passes on some of it's args to a constructor for t. This is easy as long as I don't need it to work for

Re: How to chain constructor args to a template memeber

2010-03-11 Thread BCS
Hello Lutger, Workaround if T has a single constructor, perhaps it can be generalized with some work: this(int foo, float bar, std.traits.ParameterTypeTuple!(T.__ctor) args) { t = T(args); } Not exactly ideal, but... :) -- ... IXOYE

Re: How to chain constructor args to a template memeber

2010-03-11 Thread BCS
Hello Steven, What about a static function instead of a constructor? i.e. static C create(Args...)(int foo, float bar, Args args) { auto c = new C(foo, bar); c.t = T(args); return c; } That's my fallback position. It's a shame template constructors aren't allowed, they aren't even virtual

Re: Problem with one-class-per-file approach

2010-03-08 Thread BCS
Hello Kris, Hi folks, Is it possible to split the files up to use one class per file again, but add a red.xml.xmldom module imports and exposes them somehow? Take a look at the details of import. IIRC public import does something like what you want. I was hoping it'd be something like

Re: void initialization vs alignment holes

2010-03-06 Thread BCS
Hello Strtr, Would you ever have an alignment hole if all the struct contains are basic types(excluding bool)? real, char[n], byte[n] and short[m] (for n%4 != 0 and m%2 != 0) might be an issue. -- ... IXOYE

Re: void initialization vs alignment holes

2010-03-06 Thread BCS
Hello Strtr, BCS Wrote: Hello Strtr, Would you ever have an alignment hole if all the struct contains are basic types(excluding bool)? real, char[n], byte[n] and short[m] (for n%4 != 0 and m%2 != 0) might be an issue. Sounds logical, thanks! I don't actually *know* those

Re: void initialization vs alignment holes

2010-03-06 Thread BCS
Hello Strtr, Suppose I'd still would like to use void optimizations, how do you clear the holes manually? IIRC zero filling a block is likely cheaper that zero filling holes in it. I'd avoid =void unless you know you will be copying structs into the space (that will copy the holes as

Re: is there a cleaner way to new a static sized array?

2010-02-25 Thread BCS
Hello grauzone, BCS wrote: I need a function that works like the following: T* New(T)() { return new T; } But that also works with static arrays: auto i = New!(int)(); auto a = New!(int[27])(); The cleanest solution I can think of is: T* New(T)() { return (new T[1]).ptr

Re: is there a cleaner way to new a static sized array?

2010-02-25 Thread BCS
Hello FeepingCreature, I assumed that was what you wanted. Well my bad. Maybe you should just special-case static arrays inside the function with static if. It's still ugly but it's what I'm going with for now. -- ... IXOYE

Re: is there a cleaner way to new a static sized array?

2010-02-24 Thread BCS
Hello FeepingCreature, On 24.02.2010 05:16, BCS wrote: I need a function that works like the following: T* New(T)() { return new T; } But that also works with static arrays: auto i = New!(int)(); auto a = New!(int[27])(); The cleanest solution I can think of is: T* New(T)() { return

Re: is there a cleaner way to new a static sized array?

2010-02-24 Thread BCS
Hello Daoryn, BCS Wrote: I need a function that works like the following: T* New(T)() { return new T; } But that also works with static arrays: auto i = New!(int)(); auto a = New!(int[27])(); The cleanest solution I can think of is: T* New(T)() { return (new T[1]).ptr

Re: Compile Phobos library ?

2010-02-18 Thread BCS
Hello GG, Thanks you very much for your explanation ! I got it work with gdb and got this: [...] I don't know enough about the internals to be able to help you beyond maybe converting the seg-v into an assert (but you should be able to do that yourself). Someone else might be able to do

Re: DMD on x86_64

2010-02-17 Thread BCS
Hello Brad, The other thing you could try is to take dmd out of the loop. Can you build a 32 bit c/c++ app with gcc/g++ directly? If you can't get that to work, it's unlikely that dmd will we successful either, given that it relies on gcc to invoke the linker, picking up all the right c

Re: Compile Phobos library ?

2010-02-17 Thread BCS
Hello GG, Hello ! I have already used gdb to debug program compiled with dmd, but never link gdb with DMD at same time. I found on google something like this : nameofprogram -g -d gdb But when I try with DMD like : DMD -g -d gdb [...] , the compiler DMD look for a .d file (cannot read file

Re: running an external .exe

2010-02-16 Thread BCS
Hello Funog, Is it possible to run an external .exe and have access to its standard input/output? Apparently std.process does not allow this. I think there is a pstream or PipeStream somewhere but I don't remember where I saw that. -- ... IXOYE

Re: dmd crash help

2010-02-02 Thread BCS
Hello Strtr, dmd(1.048/55/56) crashed on me: AppName: dmd.exe AppVer: 0.0.0.0 ModName: unknown ModVer: 0.0.0.0 Offset: 0002 There is a lot of crash data but I do not know where to start looking. I've also tried finding which part of the code is responsible, but I haven't

Re: dmd crash help

2010-02-02 Thread BCS
Hello Strtr, -v ended like this : semantic Cg_shader semantic abgr semantic bgra seman This is code within Derelict I think. Strange sudden break.. Stopping mid word makes me think that the output buffer didn't get flushed so something failed after the next to last line, but you don't

Re: boolean over multiple variables

2010-01-26 Thread BCS
Hello Nick, Pelle Månsson pelle.mans...@gmail.com wrote in message news:hjmmod$1io...@digitalmars.com... I think in should work for keys in an associative array and for values in a regular array. This is how it works in python. Aside from that being how Python does it, why do you see that

Re: Default Delegate Parameter

2010-01-26 Thread BCS
Hello Jesse, For the following code I get the bellow error. I'm wondering if I should be reporting a bug, or if creating default delegates is correctly prevented? .\defltdg.d(10): Error: delegate defltdg.__dgliteral3 is a nested function and cannot be accessed from main import std.stdio;

Re: Find if keys are in two dimensional associative array

2010-01-17 Thread BCS
Hello Michal, if one has double indexed aa, how to find that it contains value under keys 'a' and 123 float[int][char] aa; aa['a'][123] = 4.56; I had to make following helper function. Is there more elegant way / built in into D? float* isIn = doubleIn(123, 'a'); float* doubleIn (int i,

Re: D memory consumption/runtime speed problem

2010-01-13 Thread BCS
Hello sybrandy, Hello, I've been writing a bit of compression code and I noticed some strange behavior that's driving me a bit batty. I don't know if it's a bug with D or something I did. All I know is I can't figure it out. Below is the simplified version of the code as a single file. It

Re: Call diagram generation

2010-01-05 Thread BCS
Hello Strt, Lutger Wrote: On 01/03/2010 04:31 AM, Strt wrote: How can I generate some sort of call diagram from my D code? you can compile with (dmd) -profile and run the executable. This produces a file called trace.log which contains timings for each function and a call graph. It

Re: Memory RAM usage

2009-12-31 Thread BCS
Hello grauzone, bearophile wrote: In other benchmarks memory usage of Free Pascal is not dramatically lower, but it's usually near the top of lower memory usage in all Shootout benchmarks. No idea. I just know that FPC doesn't use GCC. I think it doesn't even link to libc! (I can't really

Re: Is there a reason for default-int?

2009-12-31 Thread BCS
Hello Ary, Don wrote: BCS wrote: Hello Ary, Don wrote: Phil Deets wrote: On Mon, 28 Dec 2009 16:18:46 -0500, Simen kjaeraas simen.kja...@gmail.com wrote: Apart from C legacy, is there a reason to assume anything we don't know what is, is an int? Shouldn't the compiler instead say

Re: define new types within templates

2009-12-30 Thread BCS
Hello teo, There was a way to define new types within templates and I think that I have seen that demonstrated here in the newsgroups, but cannot find it now. Can someone help me please? I would like to do something like this: template MyTemplate(T) { struct T ~ Struct // define FooStruct

Re: Is there a reason for default-int?

2009-12-30 Thread BCS
Hello Don, Simen kjaeraas wrote: Apart from C legacy, is there a reason to assume anything we don't know what is, is an int? Shouldn't the compiler instead say 'unknown type' or something else that makes sense? There's now an Error type in the compiler. It's gradually filtering its way

Re: Is there a reason for default-int?

2009-12-30 Thread BCS
Hello Ary, Don wrote: Phil Deets wrote: On Mon, 28 Dec 2009 16:18:46 -0500, Simen kjaeraas simen.kja...@gmail.com wrote: Apart from C legacy, is there a reason to assume anything we don't know what is, is an int? Shouldn't the compiler instead say 'unknown type' or something else that

Re: floating point verification using is?

2009-12-18 Thread BCS
Hello Steven, From my very hazy memory, I think there can even be multiple binary representations of nan, but I'm not sure. -Steve yes, IIRC NaNs can have a few bits of payload as well as there being signaling and non-signaling NaNs.

Re: %a formatting differences

2009-12-14 Thread BCS
Hello bearophile, Do you know what's causing the difference in the outouts? void main() { double d1 = 3.14159; printf(%a\n, d1); writefln(%a\n, d1); } Outputs: 0x1.921f9f01b866ep+1 0xc.90fcf80dc337p-2 A printf in C code compiled with GCC prints the same as the printf here. Bye, bearophile

Re: Immutable member functions on mutable objects

2009-11-30 Thread BCS
Hello Tomek, I've got a problem calling an immutable getter on an ordinary object. struct A { float _pole; float pole() immutable { return _pole; } } void main() { A a; auto x = a.pole; // Ouch! } Error: function hello.A.pole () immutable is not callable using argument types () immutable

Re: anonymous function/delegate usage

2009-11-12 Thread BCS
Hello Sam, Don Wrote: You need to call the delegate you've made. I missed this key point. So to summary: int a=1; int b=2; 1.nested function; 2.int c=(int a,int b){return a+b;}(a,b); 3.int c=(int,int){return a+b;}(a,b); 4.int c=(){return a+b;}(); 5.int c={return a+b;}(); How come the last

  1   2   3   >