Re: Template help - MultiAccess

2013-01-08 Thread Andrej Mitrovic
On 1/8/13, Era Scarecrow wrote: >template multiAccess(Type, string name, string attributes, >choice, bool read, bool write, T ...) { > I'm calling it with: >int choice; >writeln(multiAccess!(int, "test", "@safe nothrow pure", choice, > true, true, 'choice' is not a type,

Re: Why is immutable not possible as a result of a reduce expression?

2013-01-06 Thread Andrej Mitrovic
On 1/6/13, Jonathan M Davis wrote: > If you or someone else It's going to have to be someone else. When someone asks something on IRC/NG and another person responds with "it's because it's not a type constructor", or "it's not a storage class" I get completely thrown off and don't understand what

Re: Why is immutable not possible as a result of a reduce expression?

2013-01-05 Thread Andrej Mitrovic
On 1/6/13, Jonathan M Davis wrote: > In D, the term storage class is used for pretty much any attribute on a > variable which is not a type constructor This topic pops up in the newsgroups every once in a while[1]. Maybe we should properly document it in the docs, a special section on storage cla

Re: Beta problems... 'this' pointer in union?

2013-01-01 Thread Andrej Mitrovic
On 12/30/12, Jonathan M Davis wrote: > Looking at the code though, I'm shocked to see a function declaration in a > union. I wouldn't have thought that that was legal. It's legal in C++ and in D. I find it useful when interfacing with C++ non-POD types which have an embedded union, because it all

Re: typeid + toString = runtime error

2012-12-30 Thread Andrej Mitrovic
On 2012-12-30 17:04, Ali Çehreli wrote: >>> Application error: >>> core.exception.InvalidMemoryOperationError The basic rule is don't call or do anything which can allocate memory in a destructor. printf doesn't allocate, and if you don't do anything that allocates you should be ok. Maybe the com

Re: typeid + toString = runtime error

2012-12-30 Thread Andrej Mitrovic
On 12/30/12, Zhenya wrote: > Thank you,now all is clear for me. You can however use printf.

Re: cast(A)b is not an lvalue

2012-12-26 Thread Andrej Mitrovic
On 12/26/12, Maxim Fomin wrote: >> static if (!is(typeof(writeln))) >> alias writefln writeln; >> > What does this for? I constantly face in code samples shared in > this NG. Probably for D1 compatibility. D1 didn't have writeln.

Re: to!string and windows programming

2012-12-24 Thread Andrej Mitrovic
On 12/24/12, Phil Lavoie wrote: > I am currently going through the much recommended book > "Programming Windows" and experiencing some stuff. One of which > was formatting the hInstance and prevHInstance into a string. You need to initialize the runtime or you will get crashes as soon as the GC a

Re: structs are now lvalues - what is with "auto ref"?

2012-12-23 Thread Andrej Mitrovic
On 12/24/12, Namespace wrote: > As the title says: In dmd 2.061 structs are lvalues now You mean struct literals? They're rvalues now, this wasn't enforced before but it is now since a recent pull. Can't answer your other question, sorry.

Re: Error by building druntime

2012-12-23 Thread Andrej Mitrovic
On 12/23/12, Namespace wrote: > Is that my fault? :o > Is there any official manual for building dmd, druntime and > phobos? > You're probably building druntime 2.061 with dmd 2.060. First you need to build dmd git-head, then druntime (*with* the newly built DMD), then phobos. There are some guid

Re: does 'auto ref T' copy or not if passed rvalue

2012-12-17 Thread Andrej Mitrovic
On 12/17/12, Dan wrote: > Is it an optimization? I think it is. You can get rid of auto ref and you'll see it still doesn't copy for the second case, e.g. change signature to: void foo(S t); And only this call copies: foo(s); This one doesn't copy: foo(S(['x', 'y', 'z'])); The optimization ma

Re: Programming with windows api (windows.h)

2012-12-17 Thread Andrej Mitrovic
On 12/17/12, monarch_dodra wrote: > Am I doing it wrong, or are is the amount of ported windows > interface currently limited... std.c.windows.windows is a very thin layer around the API. There are better bindings here: http://dsource.org/projects/bindings/wiki/WindowsApi > Kinda lost here (The

Re: What to use instead of array.join if RHS is not a range?

2012-11-27 Thread Andrej Mitrovic
On 11/27/12, Jonathan M Davis wrote: > Rather, you're asking it to insert an element > between > every element in range, which is similar but not the same. In that case, which function to use? Because it already behaves in this way for strings.

Re: What to use instead of array.join if RHS is not a range?

2012-11-27 Thread Andrej Mitrovic
On 11/27/12, Jonathan M Davis wrote: > All you need to do is put it in an array. > > arr.join([s]); Still doesn't work. > S[1] s = void; > s[0] = S(0); > arr.join(s[]); Neither does that. http://d.puremagic.com/issues/show_bug.cgi?id=9082

Re: What to use instead of array.join if RHS is not a range?

2012-11-27 Thread Andrej Mitrovic
On 11/27/12, H. S. Teoh wrote: > What about std.algorithm.joiner? Same problem. Anyway here's a quick lazy (pun intended) implementation: import std.array; import std.stdio; struct MyJoiner(T) { T[] array; T sep; @property bool empty() { return array.empty; } void popFront()

What to use instead of array.join if RHS is not a range?

2012-11-26 Thread Andrej Mitrovic
This is what I want: struct S { int x; } void main() { S[] arr = [S(2), S(4), S(6)]; S s = S(0); arr.join(s); // fails here assert(arr == [S(2), S(0), S(4), S(0), S(6)]); } Calling join like that fails, specifically it fails because "s" is not a forward range (I don't know why i

Re: sort associative array by key

2012-11-23 Thread Andrej Mitrovic
On 11/23/12, dsmith wrote: > What is the best way to have a function sort an associative array > by key? The following yields a conversion error. > > double[string] aa_sort(double[string] aa) { >return aa.keys.sort; > } Hashes are unordered, you can't sort them by key because they don't pres

Re: enum detection

2012-11-22 Thread Andrej Mitrovic
On 11/22/12, Jack Applegame wrote: > How to detect enum member? > > struct A { >enum id = 10; >int b; >char c; > } > foreach(ident; __traits(allMembers, A)) { >// is ident enum or not? > } That's not an enum, that's a manifest constant. This is an enum: struct A { enum id { x = 10

Re: template ref parameter

2012-11-21 Thread Andrej Mitrovic
On 11/21/12, Jack Applegame wrote: > This problem appears also in std.signals. > There is no possibility to use functions with ref parameters as > signal handler. > > import std.signals; > > class Foo { >mixin Signal!(int); > } > class Bar { >void handler(ref int a) {} > } > > void main()

Re: Can I call the default opAssign after overloading opAssign?

2012-11-19 Thread Andrej Mitrovic
On 11/19/12, Rob T wrote: > perhaps best > done using the C libs memcopy function. I think the safest thing you can do is: void oldAssign(Type rhs) { this.tupleof = rhs.tupleof; }

Re: Compilable Recursive Data Structure ( was: Recursive data structure using template won't compile)

2012-11-13 Thread Andrej Mitrovic
On 11/13/12, Don Clugston wrote: > I recommend deskzilla lite. D is on its list of supported open-source > projects. It maintains a local copy of the entire bugzilla database, so > you're not restricted to the slow and horrible html interface. Wow, I had no idea they had this. I've added a note a

Re: Compilable Recursive Data Structure ( was: Recursive data structure using template won't compile)

2012-11-12 Thread Andrej Mitrovic
On 11/13/12, Rob T wrote: > PS: I could not figure out how to make a useful report using that > bug report tool either. You will need to register, and then use this page: http://d.puremagic.com/issues/enter_bug.cgi?product=D Then select a component (usually DMD, druntime, or Phobos). D2 is selec

Re: Pointer to string allows assigning int[]?

2012-11-12 Thread Andrej Mitrovic
On 11/12/12, Andrej Mitrovic wrote: > Yes this is a bug, especially since the string is typed as > immutable(char)[]. > My bad, the string contents aren't being modified. Not a bug.

Re: Pointer to string allows assigning int[]?

2012-11-12 Thread Andrej Mitrovic
On 11/12/12, Andrej Mitrovic wrote: > On 11/12/12, simendsjo wrote: >> It's not a bug. > > It's a bug, he's overwriting immutable data. > Ahh sorry I completely misread the code. There's no bug here actually.

Re: Pointer to string allows assigning int[]?

2012-11-12 Thread Andrej Mitrovic
On 11/12/12, simendsjo wrote: > It's not a bug. It's a bug, he's overwriting immutable data.

Re: Compilable Recursive Data Structure ( was: Recursive data structure using template won't compile)

2012-11-12 Thread Andrej Mitrovic
On 11/12/12, Andrej Mitrovic wrote: > On 11/12/12, Don Clugston wrote: >> Yeah. Though note that 1000 bug reports are from bearophile. > > Actually only around 300 remain open: > http://d.puremagic.com/issues/buglist.cgi?query_format=advanced&emailreporter2=1&

Re: Compilable Recursive Data Structure ( was: Recursive data structure using template won't compile)

2012-11-12 Thread Andrej Mitrovic
On 11/12/12, Don Clugston wrote: > Yeah. Though note that 1000 bug reports are from bearophile. Actually only around 300 remain open: http://d.puremagic.com/issues/buglist.cgi?query_format=advanced&emailreporter2=1&emailtype2=substring&order=Importance&bug_status=UNCONFIRMED&bug_status=NEW&bug_st

Re: Serialization library with support for circular references?

2012-11-10 Thread Andrej Mitrovic
On 11/10/12, nixda wrote: > You can try vibe.d bson serialization. > http://vibed.org/api/vibe.data.bson/serializeToBson It doesn't handle them either. Anyway I've implemented it for msgpack (took a whole of 30 minutes, it's a great and readable codebase), I just have to write some more extensive

Re: Serialization library with support for circular references?

2012-11-10 Thread Andrej Mitrovic
11/10/12, Andrej Mitrovic wrote: > I've been using msgpack for a while, unfortunately I've just > discovered it doesn't support serializing circular references > (http://jira.msgpack.org/browse/MSGPACK-81) Anyway I think I'll be able to hack-in circular reference

Re: Serialization library with support for circular references?

2012-11-10 Thread Andrej Mitrovic
On 11/10/12, Jacob Carlborg wrote: > Although Orange is probably not very fast and it currently only has an > XML archive. Heh yeah I'm actually reading XML into classes and then want to serialize this for faster access when re-running the app, so it probably wouldn't be a good idea to serialize

Serialization library with support for circular references?

2012-11-10 Thread Andrej Mitrovic
I've been using msgpack for a while, unfortunately I've just discovered it doesn't support serializing circular references (http://jira.msgpack.org/browse/MSGPACK-81), e.g.: import msgpack; class Foo { int x; Bar obj; } class Bar { int x; Foo obj; } void main() { auto foo =

Re: attribute bug?

2012-11-09 Thread Andrej Mitrovic
On 11/9/12, goofwin wrote: > class MyClass > { > package abstract { > void foo(); > void bar(); > ... > } > } package methods are automatically final, you can't have a virtual package method.

Re: Compilable Recursive Data Structure ( was: Recursive data structure using template won't compile)

2012-11-08 Thread Andrej Mitrovic
On 11/9/12, Nick Sabalausky wrote: > FWIW, you should be able to work around the issue by making some of the > pointers "void*". You'll lose some type safety and have to remember to > cast things correctly, but it should at least make it compile (although > I haven't tried it). Perhaps another po

Re: Extracting template parameters

2012-11-06 Thread Andrej Mitrovic
On 11/6/12, Simen Kjaeraas wrote: > In addition to Dan's answer, let me present a general solution: > > template InstantiationInfo( T ) { > static if ( is( T t == U!V, alias U, V... ) ) { > alias U Template; > alias V Parameters; > } else { > static assert(fals

Re: getters and setters not an lvalue

2012-10-31 Thread Andrej Mitrovic
On 10/31/12, Adam D. Ruppe wrote: > On Wednesday, 31 October 2012 at 22:46:17 UTC, Andrej Mitrovic > wrote: >> I wonder if this is low-hanging fruit to implement in the DMD >> frontend. > > I tried it and found getting almost there is easy... but getting > it > to wo

Re: getters and setters not an lvalue

2012-10-31 Thread Andrej Mitrovic
On 10/31/12, Michael wrote: > http://d.puremagic.com/issues/show_bug.cgi?id=8006 I wonder if this is low-hanging fruit to implement in the DMD frontend. Could we really just implement "var.property += 5;" to "var.property = var.property + 5;" or is it much more complicated than that.. I might ha

Re: Callbacks and interfacing with C

2012-10-30 Thread Andrej Mitrovic
On 10/30/12, Nick Sabalausky wrote: > Which, if any, of foo1/foo2/foo3 are extern(C)? (I know bar definitely > is.) All of them. void main() { pragma(msg, MyFn); pragma(msg, typeof(MyStruct.foo2)); pragma(msg, typeof(bar)); } extern (C) int function(int) extern (C) int function(int)

Re: exception messages

2012-10-23 Thread Andrej Mitrovic
On 10/24/12, Greg wrote: > I'm attempting to learn D through a personal project, and can't > figure out how to get the message from an exception. I don't know why Throwable is not documented (http://dlang.org/phobos/object.html#Throwable), but you can use the .msg field: import std.exception; im

Re: Reflection: is type an inner class

2012-10-20 Thread Andrej Mitrovic
On 10/21/12, Jonathan M Davis wrote: > How about checking whether it has an outer property? outer could be a user-defined property/enum.

Re: Reflection: is type an inner class

2012-10-20 Thread Andrej Mitrovic
On 10/21/12, Tyler Jameson Little wrote: > Say I have something like this: > > class A { > class B { > } > > B b; > } I can't find a way to figure out if the inner type is static or not. If it's static you don't need the outer class to instantiate it. Figuring

Re: toStringz note about keeping references

2012-10-14 Thread Andrej Mitrovic
On 10/15/12, Jonathan M Davis wrote: > snip Hmm ok, this sheds some light on things. If a C function takes a const pointer and has no documentation about ownership then maybe it's a good guess to say it won't store that pointer anywhere and will only use it as a temporary?

Re: toStringz note about keeping references

2012-10-14 Thread Andrej Mitrovic
On 10/15/12, Jonathan M Davis wrote: > I'd have to see exactly what TDPL says to comment on that accurately Maybe I've misread it. On Page 288 it says: "An immutable value is cast in stone: as soon as it's been initialized, you may as well consider it has been burned forever into the memory stor

Re: Ignoring defaults from sc.ini?

2012-10-14 Thread Andrej Mitrovic
On 10/14/12, Benjamin Thaut wrote: > Is there a way to make dmd ignore the default imports and library search > paths inside sc.ini? See http://dlang.org/dmd-windows.html#sc_ini

Re: Automated D code editing?

2012-10-13 Thread Andrej Mitrovic
On 10/13/12, Lubos Pintes wrote: > Although I thought about refactoring, which I know is not available yet, > this was very interesting example (for me as newbye). Ah ok. Well it wouldn't be too difficult to write a small D script that does this on source files. You wouldn't need a full-fledged p

Re: Why doesn't DMD recreate folder structure when using multiple .d files and -H?

2012-10-13 Thread Andrej Mitrovic
On 10/13/12, Jordi Sayol wrote: > $ dmd -op -H -o- atk/Action.d gio/DBusProxy.d -Hdinclude Damn, I never knew what -op did (it should mention it's useful for -H). Thanks.

Re: Calling un-overridden class method

2012-10-12 Thread Andrej Mitrovic
On 10/13/12, H. S. Teoh wrote: > The problem is, I can't seem to specify that I want it to _statically_ > bind the save method to call B.eval; Try using typeof(this).eval typeof(this) and typeof(super) are mentioned here: http://dlang.org/declaration.html#typeof http://dlang.org/expression.html

Re: Why doesn't DMD recreate folder structure when using multiple .d files and -H?

2012-10-12 Thread Andrej Mitrovic
On 10/13/12, Andrej Mitrovic wrote: > I didn't find an open bug report on this, but I think this is worthy > of an enhancement request. And writing header files one at a time is incredibly slow because DMD parses every import on each header generation.

Re: Why doesn't DMD recreate folder structure when using multiple .d files and -H?

2012-10-12 Thread Andrej Mitrovic
On 10/13/12, Andrej Mitrovic wrote: > On 10/13/12, Andrej Mitrovic wrote: >> I didn't find an open bug report on this, but I think this is worthy >> of an enhancement request. > > And writing header files one at a time is incredibly slow because DMD > parse

Why doesn't DMD recreate folder structure when using multiple .d files and -H?

2012-10-12 Thread Andrej Mitrovic
For example: $ dmd -H -o- atk/Action.d gio/DBusProxy.d -Hdinclude Both files are written to the 'include' folder but they're flat because the original folder structure is lost. So instead of having: include/atk/Action.d include/gio/DBusProxy.d I have: include/Action.d include/DBusProxy.d The f

Re: Unexpected OPTLINK termination

2012-10-09 Thread Andrej Mitrovic
On 10/9/12, Andrei Alexandrescu wrote: > I'd be bummed because that's quite a logical decision, and how other > interpreters do it. On second thought my solution wouldn't work. --args would still have to be passed before the D file, and people would have to remember that or it wouldn't work, same

Re: Unexpected OPTLINK termination

2012-10-09 Thread Andrej Mitrovic
On 10/9/12, Andrei Alexandrescu wrote: > On 10/9/12 12:30 PM, Faux Amis wrote: >> On a side-note, why is rdmd picky about argument order? >> >> >dmd test.d -I..\include > > Because anything after the program is considered an argument to the > program. > > Andrei > I think this is a fairly common

Re: Any sample for DFL library?

2012-10-07 Thread Andrej Mitrovic
On 10/7/12, Lubos Pintes wrote: > Hi, > There are at least two interesting GUI libraries for Windows: DGUI and > DFL. But there seems to be no sample code for DFL. Does someone have any > samples for DFL? > And yes, I know about DWT, but it is a bit heavy-weight. > There are older ones here: http

Re: version(debug)

2012-10-06 Thread Andrej Mitrovic
On 10/6/12, denizzzka <4deni...@gmail.com> wrote: > Strange, when you write to the forum then you solve problem > immediately by yourself :-) That happens to me all the time too. :)

Re: version(debug)

2012-10-06 Thread Andrej Mitrovic
On 10/6/12, denizzzka <4deni...@gmail.com> wrote: > No, debug also don't works. Debug and Assert works fine Oh right, I was thinking of this: debug { // blabla } I don't even know why there is a version(Debug) when you can use a debug block.

Re: version(debug)

2012-10-06 Thread Andrej Mitrovic
On 10/6/12, denizzzka <4deni...@gmail.com> wrote: > This is bug or feature? > http://dlang.org/version.html says what it is correct code, > because "assert" in the list of "Predefined Version Identifiers" I think that must be a typo on the website. Use version(debug) instead.

Re: Troubleshooting Linker error (Symbol Undefined)

2012-10-02 Thread Andrej Mitrovic
On 10/2/12, Jesse Phillips wrote: > Thank you, making these changes did do the trick As mentioned in the other thread I was wrong, it's extern(Windows), but implib produced an import lib which didn't quite work. coffimplib does the trick though.

Re: Accessing CoInit [is Troubleshooting Linker error]

2012-10-02 Thread Andrej Mitrovic
On 10/2/12, Jesse Phillips wrote: > I've made the changes needed to get past the linker error I'm sorry, I was completely wrong about STDAPI being extern(C). I saw EXTERN_C and immediately thought this was the calling convention, it's not: #define STDAPI EXTERN_C HRESULT STDAPIC

Re: Using Cairo library bindings on Windows

2012-10-01 Thread Andrej Mitrovic
On 10/1/12, KillerSponge wrote: > I just tested the examples and built my own small test project > with your bindings, they are working great! Thank you so much! :) > Cool, I'm glad it works for you. Btw there is a new version of Cairo out but I think CairoD hasn't yet been updated. If that's an

Re: Troubleshooting Linker error (Symbol Undefined)

2012-09-30 Thread Andrej Mitrovic
On 10/1/12, Jesse Phillips wrote: > Error 42: Symbol Undefined _VarCmp@16 P.S. as soon as pointers are involved you don't need the full type info of such a parameter to debug linker errors, so you can cut down on code when reducing. For example if you had to match this C function but are get

Re: Metaprogramming: check for ref

2012-09-30 Thread Andrej Mitrovic
On 9/30/12, jerro wrote: > I think this should work: > > template returnsRef(alias f) > { > enum bool returnsRef = is(typeof( > { > ParameterTypeTuple!f param; > auto ptr = &f(param); > })); > } Yep. We should add this to Phobos imo.

Re: Metaprogramming: check for ref

2012-09-30 Thread Andrej Mitrovic
On 9/30/12, mist wrote: > How can I: > 1) check if function returns by ref > 2) check if function parameters are ref > ..outside of function body. Is parsing typeof(func).stringof only > valid option? > See ParameterStorageClassTuple in std.traits http://dlang.org/phobos/std_traits.html I'm not

Re: Very strange problem with comparing floating point numbers

2012-09-30 Thread Andrej Mitrovic
On 9/30/12, Tommi wrote: > On Sunday, 30 September 2012 at 01:48:04 UTC, Andrej Mitrovic > wrote: >> >> Dissasembly: >> __Dmain:; Function begin, communal >> enter 12, 0 ; >> _ C8, 000C, 00 >

Re: Using Cairo library bindings on Windows

2012-09-29 Thread Andrej Mitrovic
On 9/29/12, KillerSponge wrote: > Wow, thank you so much for the quick reply and all the effort! I > am going to try this out as soon as I can (which probably won't > be until Monday, sorry..) and let you know how it works out :) No problem. I also have some samples written that use the naked C A

Re: Using Cairo library bindings on Windows

2012-09-28 Thread Andrej Mitrovic
On 9/28/12, Andrej Mitrovic wrote: > I have some win32 cairo samples on my github page. Here you go: https://github.com/AndrejMitrovic/cairoDSamples Just follow the readme instructions.

Re: Using Cairo library bindings on Windows

2012-09-28 Thread Andrej Mitrovic
On 9/28/12, Andrej Mitrovic wrote: > On 9/28/12, Andrej Mitrovic wrote: >> I have some win32 cairo samples on my github page but I have to >> updated them first, they don't compile anymore (oops!). I'll do this >> within the hour. > > Man I'm getting lin

Re: Using Cairo library bindings on Windows

2012-09-28 Thread Andrej Mitrovic
On 9/28/12, Andrej Mitrovic wrote: > I have some win32 cairo samples on my github page but I have to > updated them first, they don't compile anymore (oops!). I'll do this > within the hour. Man I'm getting linker errors, WinAPI errors when registering WndProc and app c

Re: Using Cairo library bindings on Windows

2012-09-28 Thread Andrej Mitrovic
On 9/28/12, KillerSponge wrote: > snip Well first of those bindings are broken. The _deprecated.d file is missing a module declaration. Secondly the wrapper module is using extern(System) instead of extern(C) which is why those symbols have @4 appended to them. There are object-oriented multi-p

Re: template condition

2012-09-27 Thread Andrej Mitrovic
On 9/27/12, Namespace wrote: > I mean: is there any difference by building the template? I don't > understand what "more flexible" exactly mean. I mean you can create more complex constraints. See http://dlang.org/template.html

Re: system vs. execvp ?

2012-09-22 Thread Andrej Mitrovic
On 9/23/12, Jonathan M Davis wrote: > I'd be very surprised if you were correct about this. I was wrong, it's for a different reason: http://stackoverflow.com/questions/3027320/why-first-arg-to-execve-must-be-path-to-executable

Re: system vs. execvp ?

2012-09-22 Thread Andrej Mitrovic
On 9/23/12, Peter Sommerfeld wrote: > What is wrong here? string[] cmd; cmd ~= "dmd"; cmd ~= "src/xyz.d"; int i = execvp("dmd",cmd); 1st arg should always be the app name, even though apps typically ignore/skip the first arg.

Re: how is this considered hiding methods?

2012-09-22 Thread Andrej Mitrovic
On 9/22/12, Andrej Mitrovic wrote: > I would prefer if "super.alias" meant to take overloads of all base > classes into account. Although this would be kind of counter-intuitive since 'super' already means the direct base class.

Re: how is this considered hiding methods?

2012-09-22 Thread Andrej Mitrovic
On 9/22/12, Andrej Mitrovic wrote: > Now let's say the Doo clas removes the meth overload and the alias: Sorry that should be "the Bar class".

Re: how is this considered hiding methods?

2012-09-22 Thread Andrej Mitrovic
On 9/22/12, Andrej Mitrovic wrote: > using the alias But I do think this can be further improved in the language. Take this for example: import std.stdio; class Foo { void meth(double) { writeln("Foo.meth"); } } class Bar : Foo { alias super.meth meth; void meth(i

Re: how is this considered hiding methods?

2012-09-22 Thread Andrej Mitrovic
On 9/22/12, Jonathan M Davis wrote: > But why the compiler would now require that you do that, I > don't know. If that's the way that thnigs currently are, it starts to become > a bit odd that the base class functions aren't automatically available. http://dlang.org/hijack.html There's a good re

D object model

2012-09-19 Thread Andrej Mitrovic
One of the problems with wrapping C++ is wrapping multiple-inheritance classes. You could simulate these with interfaces, e.g.: interface IRoot { } interface IBase1 : IRoot { } interface IBase2 : IRoot { } class Base1 : IBase1 { void* cppObj; } class Base2 : IBase2 { void* cppObj; } class MIClass

Re: Error: WndProc - nothrow

2012-09-18 Thread Andrej Mitrovic
On 9/18/12, Simon wrote: > No worries; I'm sure that the main reason (apart from pron) Why, I've not a clue what you speaketh of! > Though to go back to the OPs question then, that nothrow attribute is > clearly erogenous now. Also I would assume that adding a try/catch in every wndproc would s

Re: Error: WndProc - nothrow

2012-09-18 Thread Andrej Mitrovic
On 9/18/12, Simon wrote: >> That's just complete and utter bullshit. A try/catch can be set in >> WinMain, and any thrown exceptions in WndProc will propagate there. >> >> Code: >> http://dpaste.dzfl.pl/84293982 >> >> Screenshot: >> http://i.imgur.com/r5wJh.png >> > > Hmm, didn't work for me when

Re: String mixin in templates

2012-09-18 Thread Andrej Mitrovic
On 9/18/12, Andre wrote: > snip Templates introduce a new scope and in that scope 'var' doesn't exist, what you want are template mixins (note: mixin expressions and template mixins are different things): mixin template test2(string str){ void test2(){ mixin("writeln(" ~

Re: lockstep alternative for StoppingPolicy.longest

2012-09-17 Thread Andrej Mitrovic
On 9/18/12, Andrej Mitrovic wrote: > On 9/18/12, Ali Çehreli wrote: >> Then .longest with zip seems to be the way to go. > > Ah ain't that cool. It looks like it works. What does it use for the > sentinel, Type.init perhaps? > Yep just tried with floats and returns NaN. Thanks again, Ali! :)

Re: lockstep alternative for StoppingPolicy.longest

2012-09-17 Thread Andrej Mitrovic
On 9/18/12, Ali Çehreli wrote: > Then .longest with zip seems to be the way to go. Ah ain't that cool. It looks like it works. What does it use for the sentinel, Type.init perhaps?

Re: lockstep alternative for StoppingPolicy.longest

2012-09-17 Thread Andrej Mitrovic
On 9/18/12, Andrej Mitrovic wrote: > On 9/18/12, Andrej Mitrovic wrote: >> foreach (aa, bb; lockstep(arr1, arr2)) >> { >> if (aa == sentinel) >> { >> if (aa % 2 == 0) > > Gah I've messed up the simple example. If

Re: lockstep alternative for StoppingPolicy.longest

2012-09-17 Thread Andrej Mitrovic
On 9/18/12, Andrej Mitrovic wrote: > foreach (aa, bb; lockstep(arr1, arr2)) > { > if (aa == sentinel) > { > if (aa % 2 == 0) Gah I've messed up the simple example. If aa was a sentinel then it meant I wouldn't check it at all, I'd try to check 'bb' instead.

Re: lockstep alternative for StoppingPolicy.longest

2012-09-17 Thread Andrej Mitrovic
On 9/18/12, Ali Çehreli wrote: > I think you actually want .shortest, no? No I want to continue iterating as long as one of the ranges is still not empty. I'm not doing just comparisons, once there's only one range that's not empty I have to do some special checks on its elements. In simple terms

Re: Error: WndProc - nothrow

2012-09-17 Thread Andrej Mitrovic
On 9/17/12, Simon wrote: > You MUST NOT allow a D exception to > propagate out of the wndproc (or indeed any other Win32 callback > function) as the Win32 calling code has no idea how to process it and > you'll just get a crash. > That's just complete and utter bullshit. A try/catch can be set in

lockstep alternative for StoppingPolicy.longest

2012-09-17 Thread Andrej Mitrovic
I need to iterate through two arrays and do some special comparisons, but the arrays are not guaranteed to have the same length. lockstep doesn't work with the "longest" policy, e.g.: int[] a = [1, 2]; int[] b = [1, 2, 3]; foreach (aa, bb; lockstep(a, b, StoppingPolicy.longest)) // throws { } W

Re: Get identifier of "this"

2012-09-17 Thread Andrej Mitrovic
On 9/17/12, Steven Schveighoffer wrote: > Please file, ICE should never occur. You're bound to find a small million of these when it comes to typos in templates. :) http://d.puremagic.com/issues/show_bug.cgi?id=8679

Re: Get identifier of "this"

2012-09-17 Thread Andrej Mitrovic
On 9/17/12, Andre wrote: > Get identifier of "this" You can't really get that info at runtime, a class object isn't bound to a name, 'this' has no identifier. Symbols (like variables) have identifiers, not objects. > public class Bank{ Unnecessary, declarations are public by default. > pub

Re: Error: WndProc - nothrow

2012-09-16 Thread Andrej Mitrovic
On 9/17/12, cal wrote: > On Sunday, 16 September 2012 at 17:38:35 UTC, deed wrote: >> What does the nothrow stems from? Is this something new? > The change is from this commit 4 months ago: > 2886846a92c45d92308756cf4c077ae13f0f8460 https://github.com/D-Programming-Language/druntime/pull/225 I d

Re: Automatic return type covariance for functions that return this?

2012-09-15 Thread Andrej Mitrovic
On 9/15/12, Ben Davis wrote: > Never mind, I found the answer in the 'templates' page of the spec: > > class Super { > T doStuff(this T)() { ...; return cast(T)this; } > } Btw I think that's a dynamic cast, unless the compiler can optimize it (I mean it should since it's a template function r

Re: Automatic return type covariance for functions that return this?

2012-09-15 Thread Andrej Mitrovic
On 9/15/12, Ben Davis wrote: > Never mind, I found the answer in the 'templates' page of the spec: > > class Super { > T doStuff(this T)() { ...; return cast(T)this; } > } > > Sub x = (new Sub()).doStuff(); > > It seems a bit of a shame that I need the cast, but it's a small thing :) Ah the t

Re: Automatic return type covariance for functions that return this?

2012-09-15 Thread Andrej Mitrovic
On 9/15/12, Ben Davis wrote: > The last line doesn't compile because doStuff() returns Super. Is there > a way to make it return Sub without having to explicitly override the > function? You need a dynamic cast at the call site: Sub x = cast(Sub)(new Sub()).doStuff(); x will be null if doStuff

Re: const void* when wrapping C++

2012-09-15 Thread Andrej Mitrovic
On 9/15/12, Andrej Mitrovic wrote: > On 9/15/12, Andrej Mitrovic wrote: >> So the question is why is const(void)* illegal in D? > > Sorry guys this question is entirely wrong. That syntax *is* legal. I > don't know what happened last night when it failed to compile,

Re: const void* when wrapping C++

2012-09-15 Thread Andrej Mitrovic
On 9/15/12, Andrej Mitrovic wrote: > So the question is why is const(void)* illegal in D? Sorry guys this question is entirely wrong. That syntax *is* legal. I don't know what happened last night when it failed to compile, maybe it was template-related. Nuke the question.

const void* when wrapping C++

2012-09-15 Thread Andrej Mitrovic
C/C++ sometimes uses a declaration such as 'cost void*', which is a pointer to const void. D doesn't have an equivalent to this, since using const(void)* is illegal. The problem is if there are two overloads in a C++ class such as this: foo( const void* ) // equivalent to const(void)*, illegal i

Re: member function as template parameter workaround needed

2012-09-13 Thread Andrej Mitrovic
On 9/14/12, timotheecour wrote: > Also I can't pass &a.fun2 as fun2 is not static. Why not pass it as a runtime argument? void run(Fun, T...)(Fun fun, T args) { writeln(typeid(ParameterTypeTuple!(fun))); fun(args); } void test() { auto a = new A; run(&a.fun, 10); }

Re: modulename

2012-09-05 Thread Andrej Mitrovic
On 9/5/12, Jonathan M Davis wrote: > That would be _way_ harder to implement. Right, this would only work for templated functions, but maybe not worth adding then.

Re: modulename

2012-09-05 Thread Andrej Mitrovic
On 9/5/12, Jonathan M Davis wrote: > Regardless of whether it works, __FILE__ and __LINE__ should be used as > template arguments with extreme caution, because you end up with a new > instantiation for _every_ use (at least if you use both together). Honestly it would be much better if the file a

Re: modulename

2012-09-04 Thread Andrej Mitrovic
On 9/4/12, Jonathan M Davis wrote: > But it looks like we now have std.traits.moduleName, so presumably that will > do the trick. How will that do the trick if you don't have the reference to the invoking module?

Re: modulename

2012-09-04 Thread Andrej Mitrovic
9/4/12, Ellery Newcomer wrote: > On 09/04/2012 12:41 PM, Andrej Mitrovic wrote: >> __FILE__? >> > > It doesn't necessarily have the exact package hierarchy. We could really use __MODULE__ then. I think it's been asked before but I didn't see any enhancement request in buzilla.

Re: modulename

2012-09-04 Thread Andrej Mitrovic
__FILE__? On 9/4/12, Ellery Newcomer wrote: > 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. >

<    1   2   3   4   5   6   7   8   9   10   >