Re: Synchronized const methods

2010-06-11 Thread Daniel Keep
immutable means "no one can modify this." const means "someone might be able to modify this, but not you can't."

Re: Yet more OPTLINK woes

2010-05-13 Thread Daniel Keep
Some general replies: There have been three responses along the lines of "are you sure OPTLINK is running?". Quoting myself: "Invoking OPTLINK directly changes nothing." Or to be more specific: > link AstTest,AstTest,,user32+kernel32/noi+tango.lib; (zero-byte .map file pops into existence) Y

Yet more OPTLINK woes

2010-05-12 Thread Daniel Keep
That's right, it's time for everyone's favourite [1] game: guess why OPTLINK's not working! [2] *sigh* I'm writing a math eval library. There are two test applications. LexerTest only touches part of the code. AstTest touches everything. Now, the following works and creates an executable: d

Re: metaprogramming question

2010-04-18 Thread Daniel Keep
http://while-nan.blogspot.com/2007/06/wrapping-functions-for-fun-and-profit.html It shouldn't be too difficult to inject an extra parameter; just add it to the end of the call to the wrapped function after args.

Re: gdc and Make

2010-04-10 Thread Daniel Keep
bud, rebuild and xfbuild were designed so we wouldn't NEED Makefiles in the first place. Unless you've got a good reason, just use a recent dmd and xfbuild.

Re: enum values without initializer

2010-04-06 Thread Daniel Keep
bearophile wrote: > Nick Sabalausky: > >>> If you don't want that doplication you can also write: >>> enum auto f = Foo(); >> Can't you do: >> enum f = Foo(); >> ? > > In my opinion that's a semantic mess, I don't write that. auto is for > automatic local type inference and enum is to ask for

Re: tango and unicode

2010-03-31 Thread Daniel Keep
Ellery Newcomer wrote: > Is there an equivalent of std.utf.stride anywhere in tango? decode in tango.text.convert.Utf. Returns the code point at the start of the string and passes the length in code units out of the second parameter by ref.

Re: D1: Overloading across modules

2010-03-23 Thread Daniel Keep
Nick Sabalausky wrote: > In D1, is there any reason I should be getting an error on this?: > > // module A: > enum FooA { fooA }; > void bar(FooA x) {} > > // module B: > import A; > enum FooB { fooB }; alias A.bar bar; > void bar(FooB x) {} > > bar(FooB.fooB); // Error: A.bar conflicts with

Re: is pointer

2010-03-20 Thread Daniel Keep
bearophile wrote: > (I am looking for rough corners in D, or in my knowledge of D.) > > In this page: > http://www.digitalmars.com/d/2.0/templates-revisited.html > > In the section "Template Parameters" there is written: > > P:P*, // P must be a pointer type > > - > >

Re: exceptions

2010-02-24 Thread Daniel Keep
Ellery Newcomer wrote: > On 02/24/2010 03:10 AM, bearophile wrote: >> Ellery Newcomer: >>> Okay, does anyone know a good way to figure out where something like >>> this is coming from: >>> object.Exception: lengths don't match for array copy >> >> void main() { >> auto a1 = new int[5]; >>

Re: When is array-to-array cast legal, and what does actually happen?

2010-02-22 Thread Daniel Keep
> ... > > I see that neither the constructor nor the postblit is called. > Apparently the bit representation is used. This has the risk of > violating struct invariants. > > Is it legal? > > Thank you, > Ali cast is to value conversions what a tactical nuclear strike is to peaceful negotiations

Re: Commmandline arguments and UTF8 error

2010-02-22 Thread Daniel Keep
Jacob Carlborg wrote: > On 2010-02-22 15.39, Nils Hensel wrote: >> Daniel Keep schrieb: >>> If you look at the real main function in src\phobos\internal\dmain2.d, >>> you'll see this somewhere around line 109 (I'm using 1.051, but it's >>>

Re: Commmandline arguments and UTF8 error

2010-02-21 Thread Daniel Keep
Nils Hensel wrote: > Hello, group! > > I have a problem writing a small console tool that needs to be given > file names as commandline arguments. Not a difficult task one might > assume. But everytime a filename contains an Umlaut (ä, ö, ü etc.) I > receive "Error: 4invalid UTF-8 sequence". >

Re: immutable string literal?

2010-02-21 Thread Daniel Keep
strtr wrote: > On winXP (D1) I can compile/run this code without a problem. > Not even a warning. > > void main() { > char[] s= "immutable literal?"; > s[$-1] = '!'; > writefln(s); > } > Codepad runs into a segmentation fault. > http://codepad.org/NQfsRoR5 > > Why doesn't it result in a c

Re: use variant as associative array

2010-02-11 Thread Daniel Keep
GG wrote: > Yes I can't use struct and/or enum because I can't know type and number of > data that user could pass. > In this example, we talk about Month, but it could be Minutes, week... So I > try to program dynamic not static. If you're trying to program dynamically, then you're using the

Re: use variant as associative array

2010-02-11 Thread Daniel Keep
Daniel Keep wrote: > I got the following to work with Tango's Variant (dmd 1.051 + pre-0.99.9 > trunk): > > Variant[char[]][int] aa; > > aa[0] = typeof(aa[0]).init; > aa[0]["Month"] = Variant("Jan"); > aa[0]["Profit

Re: use variant as associative array

2010-02-11 Thread Daniel Keep
GG wrote: > I try to use variant as associative array with dmd2.039, > > Variant[char[]][int] aa; > aa[0]["Month"] = "Jan"; > aa[0]["Profit"] = 500; > aa[1]["Month"] = "Feb"; > aa[1]["Profit"] = 800; > > I got core.exception.rangeer...@main(28): Range violation > I'm doing something wrong ? Or

Re: D memory consumption/runtime speed problem

2010-01-13 Thread Daniel Keep
sybrandy wrote: > 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. > > ... > > Am I doing something wrong? I've tried every

Re: Getting access to the variables of an imported class

2009-12-05 Thread Daniel Keep
jicman wrote: > aalm Wrote: >> import dfl.all; >> import myform2; >> >> void main() >> { >> //Form d = new MyForm(); >> //MyForm d = new MyForm(); >> auto d = new MyForm(); >> d.text = "Hello..."; >> d.Name.text = "name"; >> d.show(); >> } > > thanks. That worked. Would you care t

Re: why can't structs implement interfaces?

2009-11-24 Thread Daniel Keep
Bill Baxter wrote: > On Tue, Nov 24, 2009 at 3:09 PM, Saaa wrote: > I wanted to do something like this: class C : I {}; struct S : I {}; S s; I[] i =[new C(), s ]; >>> Yeh, that's never going to work because that's acting as a dynamic >>> polymorphic interaface. R

Re: Using ANSI codes

2009-11-05 Thread Daniel Keep
funog wrote: > Stewart Gordon Wrote: > >> Funog wrote: >>> How can I get a D1 console program to use ANSI codes? Currently it just >>> prints the escape character like any other... >> At first I thought you meant the ANSI character set, but then I realised >> you're probably talking about ANSI.

Re: The length of strings vs. # of chars vs. sizeof

2009-11-01 Thread Daniel Keep
Rainer Deyke wrote: > Jesse Phillips wrote: >> I believe the documentation you are looking for is: >> >> http://www.prowiki.org/wiki4d/wiki.cgi?DanielKeep/TextInD >> >> It is more about understanding UTF than it is about learning strings. > > One thing that page fails to mention is that D has no

Re: version specific enum members

2009-10-29 Thread Daniel Keep
Phil Deets wrote: > Hi, is there a way to add members to an enum based on conditional > compilation symbols. I tried > > enum Tag { >A, B, >version (symbol) { > C, D, >} >E, > } > > but it doesn't work. I know I could do > > version (symbol) { >enum Tag { A, B, C, D,

Re: Error: 4invalid UTF-8 sequence :: How can I catch this?? (or otherwise handle it)

2009-10-21 Thread Daniel Keep
Charles Hixson wrote: > I want to read a bunch of files, and if the aren't UTF, then I want to > list their names for conversion, or other processing. How should this > be handled?? > > try..catch..finally blocks just ignore this error. > type stuff.d import std.stdio; import std.utf; void mai

Re: amazing function behavior

2009-10-19 Thread Daniel Keep
Zarathustra wrote: > Function is never called but why? It shouldn't even COMPILE. You can't use member functions as Windows callbacks. You haven't even used the correct calling convention on it. Callbacks for Win API functions have to be, I believe, extern(Windows), and they have to be free f

Re: Sizeof class instance

2009-10-03 Thread Daniel Keep
Daniel Keep wrote: > ... > Note: this is VERY old code, but I have no reason to think it won't > still work. I may need a little dusting off... *It* may need a little dusting off. Argh.

Re: Sizeof class instance

2009-10-03 Thread Daniel Keep
Jarrett Billingsley wrote: > On Sat, Oct 3, 2009 at 5:50 PM, Justin Johansson wrote: >> How does one determine the sizeof (in bytes) of an instance of a class in D? >> >> .sizeof works as advertised for structs, but for reference types, >> .sizeof yields the sizeof the referencing variable (effe

Re: Getting started - D meta-program question

2009-10-03 Thread Daniel Keep
Justin Johansson wrote: > There was mention** on the general discussion group that the D foreach_reverse > language construct could be replaced (emulated?) with a (D) meta-program. > > ** "Even a novice programmer can write a meta-program to replace > foreach_reverse without any runtime performan

Re: What if gc.disable at all

2009-09-24 Thread Daniel Keep
Sam Hu wrote: > Ah yes,I once translated most of Tango's tango.util.container.* into D2 > excluding one or two modules which heavily depends on Tango other modules.It > get compiled.However,the test program crashed with below error message: > Error 42:Symbol Undefined _D5tango4core6Memory2GC6a

Re: Linking in an .so on linux with rebuild?

2009-09-23 Thread Daniel Keep
Jarrett Billingsley wrote: > On Wed, Sep 23, 2009 at 1:11 AM, Daniel Keep > wrote: >> Now I just have to figure out how to fix THIS: >> >> ../build/dsss_objs/D/sandbox.minid_repl.o: In function `_Dmain': >> sandbox/minid_repl.d:(.text._

Re: Linking in an .so on linux with rebuild?

2009-09-22 Thread Daniel Keep
Jarrett Billingsley wrote: > On Wed, Sep 23, 2009 at 12:41 AM, Daniel Keep > wrote: >> I found a solution. >> >> See >> http://stackoverflow.com/questions/335928/linux-gcc-linking-ld-cannot-find-a-library-that-exists >> >> For me, I needed readline a

Re: Linking in an .so on linux with rebuild?

2009-09-22 Thread Daniel Keep
I found a solution. See http://stackoverflow.com/questions/335928/linux-gcc-linking-ld-cannot-find-a-library-that-exists For me, I needed readline and history, so I did this: $ cd /lib $ sudo ln -s libreadline.so.5 libreadline.so $ sudo ln -s libhistory.so.5 libhistory.so After that, ld didn't

Re: Linking in an .so on linux with rebuild?

2009-09-22 Thread Daniel Keep
Nick Sabalausky wrote: > I can't seem to get that to work. Tried all sorts of stuff. Off the top of > my head: > > -ll > -ll.so > "-L-l " > "-L-l .so" > -L-l -L > -L-l -L.so > > None of them were able to find the file (and, yes, the name+path are right), > and I'm not using any links. I've h

Re: delegate reference

2009-09-09 Thread Daniel Keep
Saaa wrote: > Ok, disregard my last comment :D > How should I do this then? class Foo { C* c; this(ref C c) { this.c = &c; } int invoke() { return (*c).method(); } } void main() { // ... deleg = &(new Foo(c)).invoke; } Or something similar. This is dangerous. Do n

Re: delegate reference

2009-09-09 Thread Daniel Keep
Saaa wrote: > "Daniel Keep" wrote in message > news:h88cck$1or...@digitalmars.com... >> >> Saaa wrote: >>> abstract class C >>> { >>> int method(); >>> } >>> class C2:C >>> { >>> int method() retu

Re: delegate reference

2009-09-09 Thread Daniel Keep
Saaa wrote: > abstract class C > { > int method(); > } > class C2:C > { > int method() return 2; > } > class C3:C > { > int method() return 3; > } > int delegate() deleg; > void main() > { > C c; > C2 c2 = new C2; > C3 c3 = new C3; > c=c2; > deleg = &c.method; > writefln(deleg()); // 2 >

Re: Structs by ref in D2

2009-08-22 Thread Daniel Keep
bearophile wrote: > Daniel Keep: >> In my own code, I usually record my intent by using "inout" for >> variables I intend to modify and "ref" for ones which I don't. >> Always seemed reasonable to me. > > for the compiler they mean the

Re: Structs by ref in D2

2009-08-21 Thread Daniel Keep
Steven Schveighoffer wrote: > ... > > The issue is possibly with ref. There are two reasons to use ref, 1 is > to be able to change the data referenced, 2 is for passing speed. > > 1 is bad for rvalues. 2 should be ok for rvalues. > > If there was a way to signify you only want to use ref fo

Re: Structs by ref in D2

2009-08-21 Thread Daniel Keep
Lutger wrote: > By const ref seems reasonable to allow, but by ref is bug prone. Why is it > handy? struct Vector4 { float[4] xyzw; Vector opAdd(ref Vector rhs); } Vector code can be made much faster using ref arguments, but if you use ref arguments, you can't have anything more compl

Re: deleting items from 2d arrays

2009-08-15 Thread Daniel Keep
Sergey Gromov wrote: > Fri, 14 Aug 2009 13:55:18 +1000, Daniel Keep wrote: > >> void dropElement(T)(ref T[] arr, size_t i) >> { >> assert( i < arr.length ); >> arr[i] = arr[$-1]; >> arr = arr[0..$-1]; >> } > > I think it's im

Re: deleting items from 2d arrays

2009-08-13 Thread Daniel Keep
Michael P. wrote: > Okay, so I'm making a breakout type game in D. Using Derelict. > I have a 2d array of Block type variables(not important what's in them) > declared like this: > Block[][] level; > and later load into like this: > level = loadLevel( "levels.txt", levelNumber ); > Anyways, what

Re: Semi Automated Object wrapping

2009-08-13 Thread Daniel Keep
Bill Baxter wrote: > On Thu, Aug 13, 2009 at 12:43 AM, Rory McGuire wrote: >> On Wed, 12 Aug 2009 17:03:17 -0700, Bill Baxter wrote: >> >>> On Wed, Aug 12, 2009 at 4:52 PM, Rory McGuire >>> wrote: Here is some code I wrote which enables wrapping a proxy around an object. I am using it f

Re: calling function templates

2009-08-09 Thread Daniel Keep
Jos van Uden wrote: > I noticed that I don't always have to use the bang notation for > function templates. I played around with that a little, but got > an error when I used a static array. I think it's because of a > casting problem or wrong type inference... I don't imagine it's > a bug. Just

Re: how does range.put work

2009-08-08 Thread Daniel Keep
Jos van Uden wrote: > Oliver wrote: >>> The source code for the standard library comes with the compiler. >>> If you look in std\array.d, you find this around line 279 (reflowed for >>> readability): void put(T, E)(ref T[] a, E e) { assert(a.length); a[0] = e; a = a[1 .. $]

Re: how does range.put work

2009-08-06 Thread Daniel Keep
O.K. wrote: > Hello, > could someone plz clearify what the exact semantics of "put" > are ? > Put works with an appender, but gives me a runtime exception > when using an array. > > Best regards, > Oliver The source code for the standard library comes with the compiler. If you look in std\arra

Re: byte to char safe?

2009-07-30 Thread Daniel Keep
Harry wrote: > D writef not print utf8 control? I have no idea what you're asking. To take a blind stab: writef expects any char[] you give it to be in utf8 format. Actually, EVERYTHING assumes that char[] is in utf8. > \x00 .. \x1f and \x7f .. \x9f safe for data? Again, I'm not sure what yo

Re: byte to char safe?

2009-07-30 Thread Daniel Keep
Harry wrote: > Again hello, > > char[6] t = r"again" ~ cast(char)7 ~ r"hello"; > > use only own write functions > is ok? > > thank you! I think a more significant problem is that "again\x07hello" can't possibly fit in six characters, unless you're using some crazy numbering system I'm not fa

Re: How to search for an element in the array. D2 phobos.

2009-07-12 Thread Daniel Keep
bearophile wrote: > Eldar Insafutdinov: >> I think I completely misunderstood how to use it. > > Yes, it's too much complex. It tries to do many different things in the most > efficient way possible, the result is a high complexity in usage. That's one > of the faults of Andrei's code, it's no

Re: pass variable names

2009-07-09 Thread Daniel Keep
Saaa wrote: > Is it possible to get the passed variable name � la: > -- > void functio(A...)(ref A a) > { > writefln(typeof(a[0])); > } > int i; > functio(i); // prints "i" No. You should be able to get the name using an alias: void func(alias var)() { writefln(var.stringof); } But yo

Re: Array slice length confusion

2009-07-09 Thread Daniel Keep
Tim Matthews wrote: > Kagamin wrote: >> Tim Matthews Wrote: >> >>> I thought a slice would behave slighty different due to some sort of >>> meta data that is a separate area of memory so it doesn't effect D's >>> abi. >>> >> Current plan is to introduce new type - array - into the language. > >

Re: How to release memory? (D2.0.30)

2009-07-04 Thread Daniel Keep
AxelS wrote: > @Ary Borenszweig: Good idea but I can't pipe data to a HTTP-server located > somewhere in the internet... I believe he means to read the file in chunks, sending them across the network as you get them. > OK, I tried it with C's malloc and free - but everytime I access my array,

Re: How to release memory? (D2.0.30)

2009-07-04 Thread Daniel Keep
BCS wrote: > ... The good news is that with virtual memory, all of that has almost > zero cost. What matters is how much ram you are actively using. You've obviously never used a netbook with no swap file. :)

Re: why __traits not in trait module and not name it trait

2009-06-24 Thread Daniel Keep
Sam Hu wrote: > Yes,__traits did not stole my girl friend,but isn't better to name it trait? > And I have thought I can find it in trait moudle but I was wrong. It's not in a module because it's a keyword. You don't find "function" defined in any library. As for being called __traits instead

Re: D compiler for .NET

2009-06-09 Thread Daniel Keep
Jason House wrote: > Earlier today, I tried to use the D compiler for .NET from > http://dnet.codeplex.com/ > > Beyond compilation of the compiler, I found zero instructions on what to do > next. How do I integrate the compiler into the .NET framework/visual > studio? I'd like to be able to

Re: legal identifier check

2009-05-31 Thread Daniel Keep
Saaa wrote: > ... > > I know use this (in the ddata thread above): > > foreach(char c; identifier) > { > if( !inPattern( c, `_a-zA-Z0-9`) ) > { > return false; > } > } That's not correct. http://digitalmars.com/d/1.0/lex.html#identifier

Re: Encoding problems...

2009-05-28 Thread Daniel Keep
Robert Fraser wrote: > BCS wrote: >> Reply to Robert, >> >> >>> Hmm... I'd say x.⊆(y) is preferable x.isSubsetOf(y), but it's not a >>> huge deal. >>> >> >> Only until you have to type it. I think universal alpha includes only >> the union of things that can be easily typed on standard keyboards.

Re: How many people here use stackoverflow.com?

2009-05-23 Thread Daniel Keep
Tim Matthews wrote: > On Sat, 23 May 2009 08:36:44 +1200, hasen wrote: > >> If I have some questions about D, should I ask on stackoverflow >> instead of here? Are there enough D'ers there? >> >> I personally think that asking there would bring more public attention >> to D, but it all depends

Re: DMD Modifications

2009-05-21 Thread Daniel Keep
white_man wrote: > Does it possible to modify DMD and publish it in that form. Of course with > full information about authors. Does it legal? It depends. If you ONLY modify the front-end (front-end files are identified as being licensed under GPL [1]), then you can distribute the modified fro

Re: D1/D2 co-install?

2009-05-17 Thread Daniel Keep
BCS wrote: > Does anyone have a good solution to installing both D1 and D2 on the > same system? I have... (goes to check) 10 different compilers on my system. There's \dmd\bin\dmd-default which is the only one on the PATH (and is basically a stable version of Tango and DMD). If I want to use

Re: Who wants to have some fun memory debugging?

2009-05-12 Thread Daniel Keep
Sean Kelly wrote: > ... > > At this point it's quite possible that you still have a reference to > newData in a register. If you want to be sure the collect call below > works as intended for this test, try adding: > > newData = new Data; > > here. Debugging it with ddbg under Win

Re: 3 variant questions

2009-05-12 Thread Daniel Keep
Saaa wrote: > ... >> var_arg!(T) will convert _argptr into the type you specify and it will >> also advance _argptr to the next argument. > What would happen if you'd cast it incorrectly if it wasn't a simple pointer > ? :D Same as would happen if you incorrectly cast anything. i.e. anything.

Re: 3 variant questions

2009-05-12 Thread Daniel Keep
Saaa wrote: > I just noticed D1 does have std.stdarg. > I shouldn't just search on the website :( > (where it is missing on the phobos page) > >> import std.stdarg; >> >> assert( _arguments[0] is typeid(int*) ); >> auto arg = va_arg!(int*)(_argptr); >> *arg = 10; >> >> Probably. > :D >> -- Dani

Re: 3 variant questions

2009-05-12 Thread Daniel Keep
Saaa wrote: >> Saaa wrote: >>> ... >>> Passing variadic arguments as ref I think is what I am asking for :) >> You can't. You have to explicitly take the address of the arguments. >> >> -- Daniel > > Like this ? > *_argptr = 10; > :D > > I don't know how to tell the compiler I want to write d

Re: 3 variant questions

2009-05-12 Thread Daniel Keep
Saaa wrote: > ... > Passing variadic arguments as ref I think is what I am asking for :) You can't. You have to explicitly take the address of the arguments. -- Daniel

Re: Resource availability: fonts

2009-05-05 Thread Daniel Keep
Tyro[a.c.edwards] wrote: > One cannot necessarily rely on particular font being available on a system, > and for security reasons asminsistrators restrict instalation of fonts (among > other things) onto systems in a network. I would like to know if it is > possible to embed a font into my cod

Re: how to initialize an array of typedef-ed type?

2009-05-01 Thread Daniel Keep
Jarrett Billingsley wrote: > On Sat, May 2, 2009 at 12:21 AM, Daniel Keep > wrote: > >> import std.conf; >> b = to!(long[])(a); >> >> That should work, in theory. > > In reality, it's std.conv ;) Those letters are like RIGHT NEXT to each otter

Re: how to initialize an array of typedef-ed type?

2009-05-01 Thread Daniel Keep
Jarrett Billingsley wrote: > On Fri, May 1, 2009 at 11:34 AM, MLT wrote: > >> Is there an easy way to convert arrays from one type to another? >> int[] a=[1,2,3,4] ; >> long[] b ; > > Not really. The best you can do is: > > b.length = a.length; > foreach(i, ref v; b) v = a[i]; import std.co

Re: How to get the base type of a typedef

2009-05-01 Thread Daniel Keep
bearophile wrote: > MLT: >> Is there a way to get the base type of location? > > See the BaseTypedef() template in the "templates" module of my dlibs (they > are for Phobos): > http://www.fantascienza.net/leonardo/so/libs_d.zip > > Bye, > bearophile It's probably something along the lines of:

Re: enum in template

2009-04-29 Thread Daniel Keep
Sam Hu wrote: > Hello everybody! > > Convert integral value to string literal: > > template myToString(ulong n, > string suffix=n>uint.max?"UL":"U" > { > static if (n<10) > enum myToString=cast(char)(n+'0')-suffix; //q1 > else > enum myToString=.myToString!(n/10,"

Re: Get the name of a function and the parameters?

2009-04-28 Thread Daniel Keep
Jarrett Billingsley wrote: > On Tue, Apr 28, 2009 at 3:07 PM, grauzone wrote: >> I'd like to pass several functions at once. Is there a way to make this >> variadic? The obvious approach (writing "NameOfFunc(alias f...)") fails with >> a syntax error. > > Sure, you'd just make it NameOfFunc(f..

Re: Get the name of a function and the parameters?

2009-04-26 Thread Daniel Keep
Daniel Keep wrote: > > Jacob Carlborg wrote: >> Is it possible to get the name of a function and the names of the >> function parameters? > > I don't believe so, no. > > -- Daniel I should perhaps qualify, in light of Jarrett's response, that I th

Re: Get the name of a function and the parameters?

2009-04-26 Thread Daniel Keep
Jacob Carlborg wrote: > Is it possible to get the name of a function and the names of the > function parameters? I don't believe so, no. -- Daniel

Re: i need a serialization framework for d

2009-04-23 Thread Daniel Keep
BCS wrote: > http://stackoverflow.com/questions/783482/i-need-a-serialization-framework-for-d Put my AU$0.02 in. > OT: would anyone be interested in a one way stackoverflow->NNTP hookup > kinda like is used with the bugzilla? I think that'd be pretty cool; have it post questions to D.learn so

Re: Documentation on DMD source

2009-04-19 Thread Daniel Keep
Unknown W. Brackets wrote: > You'll get a lot of use out of defining the debugs for #ifdefs, and/or > uncommenting printfs and following it. > > If your code may not be running, use a breakpoint or printf to ensure it > is. > > -[Unknown] I finally found out why my changes weren't working. Be

Re: Documentation on DMD source

2009-04-18 Thread Daniel Keep
Daniel Keep wrote: > Is there any guide to, or documentation for the DMD compiler source? > > I'm currently trying to make TypeInfo_Function not completely useless, > but I'm not sure my code is actually being run. > > -- Daniel Found this page: http://www

Documentation on DMD source

2009-04-18 Thread Daniel Keep
Is there any guide to, or documentation for the DMD compiler source? I'm currently trying to make TypeInfo_Function not completely useless, but I'm not sure my code is actually being run. -- Daniel

Re: Widening a type

2009-04-16 Thread Daniel Keep
Doctor J wrote: > OK, here's one for you that sounds like it ought to be easy, but I don't > immediately see how to do it in a pretty way. > > Given a type parameter T of a template: > If T is an integral type, I want to declare a variable 'widest' of type ulong; > If T is a floating-point type

Re: static initialization of associative arrays

2009-04-15 Thread Daniel Keep
Tyro[a.c.edwards] wrote: > Is it yet possible to statically initialize an associative array? If so, > please point me to the documentation. I am using DMD v2.028. > > Currently I'm able to do this: > > import std.stdio; > > string[string] types; > static this(){ > types = [ "void":"void",

Re: D1 and read-only views?

2009-04-12 Thread Daniel Keep
As others have stated, your surmise is correct. On a related note, I recently wrote a very simple cstring struct that acts like const(char)[] does in D2. I was using unique interned strings, and didn't want any surprises. You can still get a mutable reference to the string by using .toString, b

Re: Class templates with types determined at runtime

2009-04-07 Thread Daniel Keep
The major problem with this is that you're trying to get into a situation where you don't know the type of T at compile-time, and you CANNOT do that. For example, your newContainer function can't return a "Container" because "Container" isn't a concrete type; it's just a template. The only thing

Re: cast a LinkSeq

2009-04-06 Thread Daniel Keep
Qian Xu wrote: > Adam Burton wrote: >> I wouldn't think so, cos LinkSeq!(Apple) does not inherit >> LinkSeq!(Fruit), they are 2 separate types. However your apples >> automatically downcast (or up, depending which way you like to draw >> your diagrams :-) ) so unless you intend to pass the LinkS

Re: Wht std.complex is needed?

2009-04-06 Thread Daniel Keep
Steven Schveighoffer wrote: > On Mon, 06 Apr 2009 08:36:18 -0400, Don wrote: > >> Sam Hu wrote: >>> Thank you! >>> Anothe silly question then:What's the disadvantage to have the >>> built-in type of i-type? >>> Regards, >>> Sam >> >> It's a very nasty type. It supports *, but isn't closed unde

Re: project euler #10: optimization with primes

2009-04-01 Thread Daniel Keep
Robert Fraser wrote: > bearophile wrote: >> import d.func, d.primes, d.string; >> void main() { >> const int N = 1_000_000_000; >> putr( sum(xtakeWhile((int i){ return i < N;}, xprimes(N))) ); >> } > > Yeah that's shorter (vertically; it's almost as long in characters), but > how much li

Re: Universel toString

2009-03-20 Thread Daniel Keep
grauzone wrote: > Daniel Keep wrote: >> >> Qian Xu wrote: >>> Hi All, >>> >>> I want to write an universel toString() method for debugging propose. >>> However I cannot write in one version. The compiler says error all >>> the ti

Re: Universel toString

2009-03-20 Thread Daniel Keep
Qian Xu wrote: > Hi All, > > I want to write an universel toString() method for debugging propose. > However I cannot write in one version. The compiler says error all the time. > Could someone tell me, how to write an universel one? > > What I want, is to convert primtive types (int, int*, boo

D2: bug in struct postblit/dtor, or am I a burke?

2009-03-17 Thread Daniel Keep
Hi all. I can't seem to get this to work properly. I'm trying to write a copy-on-write proxy type. I'm using postblit and dtors along with the usual ctors and opAssign to manage the refcount of the shared memory. However, testing with dmd-2.026 (and a few previous versions a little while ago),

Re: C-style nested structs convert to D

2009-03-17 Thread Daniel Keep
CodexArcanum wrote: > Hey all, I'm trying to rewrite a few .h files into D so I can call a C > library. One snag I've hit is this guy: > > struct _tree_t { > _tree_t* next; > _tree_t* father; > _tree_t* sons; > } > > D won't do the nested struct thing, so I need to convert thi

Re: lvalue - opIndexAssign - Tango

2009-03-13 Thread Daniel Keep
The Anh Tran wrote: > Hi, > > When porting from c++ to D, i encounter this strange discrimination: > 1. Built-in AA: > int[int] arr; > arr[123] += 12345; > arr[321]++; > > 2. Tango HashMap: > auto hm = new HashMap!(int, int)(); > hm[123] += 12345; // error not lvalue > h

Re: recognizing asciiz, utf ...

2009-03-13 Thread Daniel Keep
newbee wrote: > Jarrett Billingsley Wrote: > >> On Fri, Mar 13, 2009 at 3:04 PM, newbee wrote: >>> Hi all, >>> >>> How does one check for asciiz, utf ...? >>> I do get a buffer with characters as parameter in a function, but i don�t >>> know if it is asciiz or utf or wchar. Is it possible to f

Re: enum to string

2009-03-13 Thread Daniel Keep
Ary Borenszweig wrote: > Lionello Lunesu wrote: >> >> "Brad Roberts" wrote in message >> news:alpine.deb.2.00.0903121755240.4...@bellevue.puremagic.com... >>> That said, I don't think this really helps the desired usecase much. >>> It's >>> useful, don't get me wrong, but still requires code to

Re: # operator under C implementation in D1

2009-03-12 Thread Daniel Keep
Sam Hu wrote: > I know a little that in C there is a # operator which under a macro can > return any type's value in character format.Just wanna know whether there is > an equivelent implementation in D1.Say,in C using a/m macro can easily output > enum's character value other than integer.It

Re: Newbie question: COM programming and linking to Windows libraries

2009-03-11 Thread Daniel Keep
Patrick Kristiansen wrote: > ... > > Now, this is probably obvious to some people - but not to me. Why doesn't > this work? Why does OPTLINK fail and tell me that the format of the .lib file > is wrong? Is it because Digital Mars compilers produce .lib files in a > different format? Is it bec

Re: enum to string

2009-03-10 Thread Daniel Keep
Nick Sabalausky wrote: > Is there any way to do this (preferably in D1) with reflection? (ie, without > having to manually create a conversion func/lookup for every value of every > enum.) > > -- > enum Shape > { > Square, Circle > } > char[] foo(Shape s) > { > // ?

Re: array and pointer

2009-03-05 Thread Daniel Keep
takeshi wrote: > Hello, I have just started learning D. > > I cannot compile the code in the documentation on array and pointer > either with dmd (D 2.0) and gdmd (D 1.0). > > Is some compile option or cast required? > > int* p; > int[3] s; > p = s; If that's the example, then it's out of dat

Re: Reading and writing Unicode files

2009-02-28 Thread Daniel Keep
jicman wrote: > Ok, the only reason that I say Unicode is that when I open the file in > Notepad and I do a SaveAs, the Encoding says Unicode. So, when i read this > file and I write it back to the another file, the Encoding turns to UTF8. I > want to keep it as Unicode. There is no such th

Re: Reading and writing Unicode files

2009-02-28 Thread Daniel Keep
jicman wrote: > downs Wrote: > >> downs wrote: >>> jicman wrote: Greetings. Sorry guys, please be patient with me. I am having a hard time understanding this Unicode, ANSI, UTF* ideas. I know how to get an UTF8 File and turn it into ANSI. and I know how to take a ANS

Re: Any way to track memory allocations?

2009-02-24 Thread Daniel Keep
Jarrett Billingsley wrote: > On Tue, Feb 24, 2009 at 8:23 PM, Daniel Keep > wrote: > >> Yup. >> >> It's a pity that we don't have, oh I don't know, some sort of efficient >> iterable interface that doesn't cause a heap allocation that the

Re: Dynamic Array Garbage collection

2009-02-24 Thread Daniel Keep
Jarrett Billingsley wrote: > On Tue, Feb 24, 2009 at 6:45 PM, Daniel Keep > wrote: > >> Maybe it's because I just woke up, but I can't see how that code could >> compile anyway, since you can't pass a short[] to a function expecting >> an int[]. >

Re: Any way to track memory allocations?

2009-02-24 Thread Daniel Keep
wade wrote: > Thanks again for all the help. I found what the problem was and it wasn't > obvious (at least to me): > > float[uint] arr; > > foreach (uint k; arr.keys) > { > ... > } > > Changing this to: > > foreach (uint k, float v; arr) > { > > } > > fixes the leak. I guess the ke

Re: Generic functions to convert to void* and from void*

2009-02-24 Thread Daniel Keep
TSalm wrote: > In my case, there's also no possibility to get the wrong type, because > it is managed by the type of the ColumnMem. You still have to get the code right. There's a surprising number of corner cases trying to store arbitrary types. > And about Object, if I want to store base type

  1   2   >