Re: Derelict SFML destructor crashes

2012-12-17 Thread Rob T
On Monday, 17 December 2012 at 04:40:39 UTC, Mike Parker wrote: First, please take all Derelict trouble-shooting problems to the Derelict forums[1]. I'm posting here because I was unable to register with the derelict forum. I filled out the registration form and press the register button, t

Re: guidelines for parameter types

2012-12-17 Thread Ali Çehreli
Thank you very much for doing the hard work on this. I find this kind of information very important. On 12/17/2012 12:46 PM, Dan wrote: > Assume V is a non-template parameter type and v is a parameter of that > type for any function. Also assume T is a template parameter type and t > is a parame

Help with Out Of Memory D v1.0

2012-12-17 Thread jose isaias cabrera
Greetings! I have this program that zips a file and everything works perfectly, if the files are small enough. But, I am having to zip files that are getting more and more extreme in size and I am running out of memory. Here is the output when executing a small program to zip a folder: 0:

Help with out of memory when using zip

2012-12-17 Thread jicman
Greetings! I have this program that zips a file and everything works perfectly, if the files are small enough. But, I am having to zip files that are getting more and more extreme in size and I am running out of memory. Here is the output when executing a small program to zip a folder: 0:

Re: Derelict SFML destructor crashes

2012-12-17 Thread Jeremy DeHaan
On Tuesday, 18 December 2012 at 01:24:43 UTC, Mike Parker wrote: No, that's a bad idea. What if the C library you are using maintains some sort of internal bookkeeping related to the pointer? What if it keeps a copy of the pointer internally? If the GC collects your D-side pointer, how is the

Re: variable x cannot be read at compile time (ctfe)

2012-12-17 Thread js.mdnq
On Monday, 17 December 2012 at 22:47:33 UTC, bearophile wrote: maarten van damme: How do I make dmd output asm? You can't, unfortunately. They closed this enhancement request of mine because they say DMD is not designed for this. On Linux there are several disassemblers, I use objdump. On

Re: Derelict SFML destructor crashes

2012-12-17 Thread Mike Parker
On Monday, 17 December 2012 at 22:08:08 UTC, Jeremy DeHaan wrote: It's not the only way, but it's the easiest way. What are some other ways? I am just curious. You could use module destructors to cleanup at program exit and use RAII via struct destructors for short-lived objects. Also,

Re: Writing unicode strings to the console

2012-12-17 Thread Adam D. Ruppe
On Tuesday, 18 December 2012 at 00:59:12 UTC, Jeremy DeHaan wrote: How/Where would I call this? Right at the beginning of your main, but after trying it, I don't think this is going to fix your problem anyway... I think it is fonts. But: import std.stdio; extern(Windows) int SetConsoleOutp

Re: Writing unicode strings to the console

2012-12-17 Thread Jeremy DeHaan
@Adam D. Ruppe I suggest you use string instead of dstring, because utf-8 (string) has better output support than utf-32 (dstring), and both support the complete unicode character set. Tried string and wstring. Both had the same results as my dstring. On Windows, the api call SetConsoleOutpu

Re: Writing unicode strings to the console

2012-12-17 Thread H. S. Teoh
On Tue, Dec 18, 2012 at 01:29:55AM +0100, Jeremy DeHaan wrote: > I was playing with unicode strings the other day, and have been > searching for a way to correctly write unicode to the console. > > If I try something like: > > dstring String = "さいごの果実"; > > writeln(String); > > Al

Re: Writing unicode strings to the console

2012-12-17 Thread bearophile
Jeremy DeHaan: Is it possible to write the unicode string to the console correctly? What is your operating system? On oldish Windows you have to set the console to Unicode or nearly Unicode. I don't know about Windows7/8. Bye, bearophile

Re: Writing unicode strings to the console

2012-12-17 Thread Adam D. Ruppe
I suggest you use string instead of dstring, because utf-8 (string) has better output support than utf-32 (dstring), and both support the complete unicode character set. If string doesn't work, the question is: Windows or Linux? On Windows, the api call SetConsoleOutputCP will help http://msd

Writing unicode strings to the console

2012-12-17 Thread Jeremy DeHaan
I was playing with unicode strings the other day, and have been searching for a way to correctly write unicode to the console. If I try something like: dstring String = "さいごの果実"; writeln(String); All I get is a bunch of nonsense as if it converts the dstring into a regular st

Re: Get specific functions of unknown type at runtime?

2012-12-17 Thread F i L
Okay, thanks for the help folks.

Re: static code generation

2012-12-17 Thread r_m_r
On 12/18/2012 04:42 AM, js.mdnq wrote: In any case, it seems your method does not work with methods? if I add the `check()` to your approach-2 it fails with several strange errors. Any ideas? approach-2 can only combine struct fields (i.e., no method support - for that you have to use approac

Re: alias this/opGet and opCast conversion

2012-12-17 Thread js.mdnq
On Monday, 17 December 2012 at 15:46:22 UTC, anonymous wrote: On Monday, 17 December 2012 at 15:10:24 UTC, js.mdnq wrote: This i probably a rather dumb question but I've been up all night and therefor have a really good excuse ;) (I can barely see straight...) Is opGet the reverse opAssign?

Re: static code generation

2012-12-17 Thread js.mdnq
On Monday, 17 December 2012 at 22:24:58 UTC, r_m_r wrote: On 12/17/2012 04:33 AM, js.mdnq wrote: Well, it a slightly another way and close. Let me see if I can come up with something that expresses better what I'm after. It will be a week or two though till I get around to it probably. OK. I

Re: variable x cannot be read at compile time (ctfe)

2012-12-17 Thread Ali Çehreli
On 12/17/2012 02:47 PM, bearophile wrote: maarten van damme: How do I make dmd output asm? You can't, unfortunately. They closed this enhancement request of mine because they say DMD is not designed for this. On Linux there are several disassemblers, I use objdump. On Windows there are other

Re: variable x cannot be read at compile time (ctfe)

2012-12-17 Thread bearophile
maarten van damme: How do I make dmd output asm? You can't, unfortunately. They closed this enhancement request of mine because they say DMD is not designed for this. On Linux there are several disassemblers, I use objdump. On Windows there are other ones. Bye, bearophile

Re: variable x cannot be read at compile time (ctfe)

2012-12-17 Thread maarten van damme
How do I make dmd output asm? I wrote a simple test and for a simple int[] array it was 2,5 times slower. 2012/12/17 bearophile : > maarten van damme: > > >> it's odd that the resulting arraylist is slower to access at runtime >> then the arraylist generated at runtime... Is there a reason for th

Re: static code generation

2012-12-17 Thread r_m_r
On 12/17/2012 04:33 AM, js.mdnq wrote: Well, it a slightly another way and close. Let me see if I can come up with something that expresses better what I'm after. It will be a week or two though till I get around to it probably. OK. I'll just leave this here for future reference: http://dpaste.

Re: Derelict SFML destructor crashes

2012-12-17 Thread Jeremy DeHaan
It's not the only way, but it's the easiest way. What are some other ways? I am just curious. Also, if we were able to know the size of the object the pointer is referring to, couldn't we then add it to the GC? It sounds like a pretty complicated way, but wouldn't that be a good way if it w

Re: guidelines for parameter types

2012-12-17 Thread Dan
On Monday, 17 December 2012 at 21:12:16 UTC, bearophile wrote: Are in, out, scope, std.typecons.Nullable, std.typecons.Rebindable missing in your table? Bye, bearophile Not at all - I cringe at the thought of dealing with those as well now. But if you want to give them a go as well I'd be gl

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

2012-12-17 Thread Jonathan M Davis
On Monday, December 17, 2012 06:21:38 PM Dan wrote: > For the code below, S is never copied even though a version of > the function resolving to void x.foo!(x.S).foo(x.S) is called. > How is this possible? > Is it an optimization? I figure if I call a function that takes > its parameter by value, t

Re: variable x cannot be read at compile time (ctfe)

2012-12-17 Thread bearophile
maarten van damme: it's odd that the resulting arraylist is slower to access at runtime then the arraylist generated at runtime... Is there a reason for this? In such cases, beside thinking some time about the topic, one solution is to take a look at the asm. Maybe it's the same problem as

Re: guidelines for parameter types

2012-12-17 Thread Dan
On Monday, 17 December 2012 at 20:46:27 UTC, Dan wrote: Sorry, here is the table more legible: http://pastebin.com/0bFSL0Xz

guidelines for parameter types

2012-12-17 Thread Dan
Assume V is a non-template parameter type and v is a parameter of that type for any function. Also assume T is a template parameter type and t is a parameter of that type for any function. Is the following table and set of guidelines below reasonable? What other guidelines do you use or would m

Re: variable x cannot be read at compile time (ctfe)

2012-12-17 Thread maarten van damme
Thanks, I'm really happy it works now. it's odd that the resulting arraylist is slower to access at runtime then the arraylist generated at runtime... Is there a reason for this? Should I open bugreports for your testcases? 2012/12/17 bearophile : >> I think it's a problem of nested delegates at

Re: Programming with windows api (windows.h)

2012-12-17 Thread John Chapman
HGLOBAL data = GetClipboardData(CF_TEXT); Oops, should be CF_UNICODETEXT (13)

Re: Programming with windows api (windows.h)

2012-12-17 Thread John Chapman
On Monday, 17 December 2012 at 16:21:09 UTC, monarch_dodra wrote: I'm a bit confused about how to interface with windows.h. All I'm trying to do is retrieve some text from my clipboard to print it. Something like this: HWND hwnd = ... // your window handle (or null) if (OpenClipboard(hwnd))

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

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

2012-12-17 Thread Dan
For the code below, S is never copied even though a version of the function resolving to void x.foo!(x.S).foo(x.S) is called. How is this possible? Is it an optimization? I figure if I call a function that takes its parameter by value, there should be a copy. Thanks Dan --- Output

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

Programming with windows api (windows.h)

2012-12-17 Thread monarch_dodra
I'm a bit confused about how to interface with windows.h. All I'm trying to do is retrieve some text from my clipboard to print it. So far, I have this: // import std.stdio; import core.sys.windows.windows; extern (Windows) { HWND GetClipboardOwner(); BOOL OpenClipboard(HWND hWn

Re: alias this/opGet and opCast conversion

2012-12-17 Thread anonymous
On Monday, 17 December 2012 at 15:10:24 UTC, js.mdnq wrote: This i probably a rather dumb question but I've been up all night and therefor have a really good excuse ;) (I can barely see straight...) Is opGet the reverse opAssign? I can't find any docs on it but it does let me write converter

alias this/opGet and opCast conversion

2012-12-17 Thread js.mdnq
This i probably a rather dumb question but I've been up all night and therefor have a really good excuse ;) (I can barely see straight...) Is opGet the reverse opAssign? I can't find any docs on it but it does let me write converters from my type to another type. e.g., struct X { int value

Re: variable x cannot be read at compile time (ctfe)

2012-12-17 Thread bearophile
I think it's a problem of nested delegates at CT. But if this is the problem, dmd used to give a more clear error message. Two minimized programs that show the problems: - import std.algorithm: filter; import std.array: array; auto foo(in int x) { return [1, 2].filter!(i => x)(

Re: Get specific functions of unknown type at runtime?

2012-12-17 Thread Adam D. Ruppe
On Monday, 17 December 2012 at 07:54:08 UTC, F i L wrote: I have an alternative in mind, but first, is there a possible way for a Super class to ask about a derivative's members during constructions? (I'm guessing not). Something like: Not that I know of, no. Though maybe a templated construct

Re: variable x cannot be read at compile time (ctfe)

2012-12-17 Thread bearophile
maarten van damme: Here is a trimmed down version : http://dpaste.dzfl.pl/11170641 thanks for the quick reply. It seems to work if you move ".array()" from generateBitsetCache() to bitsetToRange(). I think it's a problem of nested delegates at CT. But if this is the problem, dmd used to gi

Re: Derelict SFML destructor crashes

2012-12-17 Thread Nekroze
On Monday, 17 December 2012 at 14:06:30 UTC, Mike Parker wrote: Now what i was thinking as a solution, would it be possible to manually run the GC cleanup pass at the end of main this way we know that the GC cleanup would run before main exits and thus sfml gets unloaded. Although i believe thi

Re: Derelict SFML destructor crashes

2012-12-17 Thread Mike Parker
On Monday, 17 December 2012 at 12:08:29 UTC, Nekroze wrote: Structs have their destructors called, as far as i understand, as soon as you go out of the scope they are defined in. Not sure how that works with structs that are members of a class but i assume that has the same problems as a clas

Re: Derelict SFML destructor crashes

2012-12-17 Thread Mike Parker
On Monday, 17 December 2012 at 10:39:56 UTC, Jeremy DeHaan wrote: I tried putting destroy in the destructor like the code I wrote. Like I said, it gave me no memory errors, but I don't actually know if it even does anything. I honestly think that it is weird to not be able to rely on destruct

Re: variable x cannot be read at compile time (ctfe)

2012-12-17 Thread bearophile
maarten van damme: I always get "variable x cannot be read at compile time" in this method : auto bitsetToRange(in SudokuCell x) { return boardSide.iota().filter!(i => (x >> i) & 1)().map!(x=>x+1)(); } with SudokuCell beeing declared as: alias ushort SudokuCell; Why don't you show us

Re: Derelict SFML destructor crashes

2012-12-17 Thread Nekroze
On Monday, 17 December 2012 at 12:08:29 UTC, Nekroze wrote: Now what i was thinking as a solution, would it be possible to manually run the GC cleanup pass at the end of main this way we know that the GC cleanup would run before main exits and thus sfml gets unloaded. Although i believe this st

Re: Derelict SFML destructor crashes

2012-12-17 Thread Nekroze
On Monday, 17 December 2012 at 10:56:23 UTC, Jeremy DeHaan wrote: Does that mean that putting some form of delete in a struct destructor will be called to delete contents or is that still considered unsafe? And why don't classes have the same guarantee? Is it because they are a reference typ

Re: variable x cannot be read at compile time (ctfe)

2012-12-17 Thread monarch_dodra
On Monday, 17 December 2012 at 09:42:50 UTC, maarten van damme wrote: I finally got around trying to finish my sudoksolver and I'm pretty happy with the result, except one little piece that screams for ctfe but I never seem to get it working. I always get "variable x cannot be read at compile t

Re: Derelict SFML destructor crashes

2012-12-17 Thread Jeremy DeHaan
On Monday, 17 December 2012 at 09:52:08 UTC, Jacob Carlborg wrote: On 2012-12-17 09:23, Jeremy DeHaan wrote: And how does calling destroy/delete in a struct destructor differ from doing the same in a class destructor? I too would like to make sure I am not getting any memory leaks! Because

Re: Derelict SFML destructor crashes

2012-12-17 Thread Jeremy DeHaan
Thanks for all the info, Mike. I come from a C# background, so I have pretty much 0 experience when it comes to handling memory myself(let alone working with a binding to another language) and I haven't read my D book as much as I would like. I'm not quite sure what you are referring to when y

Re: Derelict SFML destructor crashes

2012-12-17 Thread Jacob Carlborg
On 2012-12-17 09:23, Jeremy DeHaan wrote: And how does calling destroy/delete in a struct destructor differ from doing the same in a class destructor? I too would like to make sure I am not getting any memory leaks! Because there are guarantees how and when a destructor for a struct is called

variable x cannot be read at compile time (ctfe)

2012-12-17 Thread maarten van damme
I finally got around trying to finish my sudoksolver and I'm pretty happy with the result, except one little piece that screams for ctfe but I never seem to get it working. I always get "variable x cannot be read at compile time" in this method : auto bitsetToRange(in SudokuCell x) { return bo

Re: Get specific functions of unknown type at runtime?

2012-12-17 Thread Jacob Carlborg
On 2012-12-17 08:54, F i L wrote: @Adam D. Ruppe Damn, I was afraid you where going to say to do something like that. It doesn't really work for what I'm thinking about, but thanks for confirming that my original code can't work. I have an alternative in mind, but first, is there a possible way

Re: Derelict SFML destructor crashes

2012-12-17 Thread Mike Parker
On Monday, 17 December 2012 at 08:23:02 UTC, Jeremy DeHaan wrote: I am somewhat confused by some things that are being talked about in this thread. Mike Parker said that this Image is handled by GC. Would that mean that any class members are handled by the GC too? If so, wouldn't the sfImage*

Re: Derelict SFML destructor crashes

2012-12-17 Thread Jeremy DeHaan
I am somewhat confused by some things that are being talked about in this thread. Mike Parker said that this Image is handled by GC. Would that mean that any class members are handled by the GC too? If so, wouldn't the sfImage* be collected by the GC? If not, and you DO need to manually dele