Re: Windows Header consts

2015-09-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 7 September 2015 at 17:44:54 UTC, Prudence wrote: const WM_* -> add to enum WM; else WM_* -> WM.* I'm against that. The documentation all says WM_* and we shouldn't muck with it. const -> enum is a good idea though. These headers were all written way back when when const and

Re: Windows Header consts

2015-09-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 7 September 2015 at 23:11:36 UTC, Prudence wrote: I asked is there is an easy way to do it, and you replied that essentially that it shouldn't be changed because it would change things. I also said: I guessing one would need a D or C parser to deal with all this? hackerpilot's

Re: Windows Header consts

2015-09-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 7 September 2015 at 22:02:47 UTC, Prudence wrote: Oh, and who says you couldn't keep both systems? Nobody. There's absolutely nothing stopping you from defining your one constants and bindings. I think you should actually do it and see for yourself the pros and cons in practice.

Re: OSX prompt limit

2015-09-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 8 September 2015 at 13:17:31 UTC, Ola Fosheim Grøstad wrote: Or just take it from the man page: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/signal.3.html ah excellent. My web search came up with

Re: Create a delegate function

2015-09-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 5 September 2015 at 18:00:53 UTC, Prudence wrote: I have code setup in such a way that I call a user defined function, e.g., void myFunc(Data d) { } myFunc has to be passed to the main code using something like You can do that if and only if the this is the last argument

Re: Windows Resources

2015-09-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 6 September 2015 at 10:28:59 UTC, Kagamin wrote: You do. See docs for lpszMenuName field. I can't believe I missed that!

Re: Abstractioning away main/winMain

2015-09-04 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 5 September 2015 at 01:43:43 UTC, Prudence wrote: extern (Windows) int WinMain(...) If you use WinMain in D, you'll also have to initialize the D runtime yourself, which will call static constructors and such. You'd be better off just using a regular main() function, then

Re: Call a function passed as template parameter.

2015-09-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 3 September 2015 at 11:31:22 UTC, moechofe wrote: I would like to create a template that take a function as template parameter, create an arguments list for it, fill it with some data and call the function. Check out the sample chapter to my book:

Re: OSX prompt limit

2015-09-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 4 September 2015 at 02:17:57 UTC, Joel wrote: In Mac OS, when typing with readln etc. I can't use the cursor keys. Works in Windows though. That's normal, line editing on Unix terminals is a kinda advanced library feature. The most common lib to do it, GNU readline, is actually a

Re: OSX prompt limit

2015-09-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 8 September 2015 at 06:24:12 UTC, Joel wrote: arsd/terminal.d(1268): Error: undefined identifier 'SIGWINCH' There's a missing value in the signal header for OSX ! Could you run this little C program for me on your Mac and let me know the output? --- #include #include int

Re: Windows Header consts

2015-09-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 7 September 2015 at 19:06:48 UTC, Prudence wrote: It's called encapsulation. It prevents namespace pollution and identifier collision. This is already provided by the D module system. Even if you were to define a WM_CREATE in your code, it would not cause a major problem with the

Re: Windows Header consts

2015-09-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 7 September 2015 at 18:42:59 UTC, Prudence wrote: because it is confusing and hard for you to understand over Nope, I'm saying it is a pointless change. If you do that, EVERY time you want to look something up, you need to rewrite WM.* into WM_* since that's what the docs say. And

Re: friends with phobos, workaround?

2015-09-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 23:44:14 UTC, Idan Arye wrote: public: mixin MakeUnique!(int); I actually think that should be a free function in the module because then it can be used by derived classes too without having to mix it in each of them as well.

Re: friends with phobos, workaround?

2015-09-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 10 September 2015 at 08:22:29 UTC, Daniel N wrote: this(string caller = __MODULE__)(int val) if(caller == "std.conv") // Use scoped!Awesome That's disgustingly genius. I'm a bit jealous I didn't think of it myself! One slight problem though: you couldn't call super() from

Re: Is D suitable for my latest project?

2015-09-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 10:23:55 UTC, chris stevens wrote: http://wiki.dlang.org/Dynamic_typing This is what I saw that made me think that I could. Have had another closer look and I do believe it's possible. These are things I wrote, so let me explain how they work: they do not

Re: class destruction

2015-09-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 15:24:57 UTC, Q wrote: I thought that is not guaranteed, according to the docs? It is possible that the GC will never actually run, but you can force it to if you need it to by calling GC.collect at any time.

Re: class destruction

2015-09-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 15:37:50 UTC, Q wrote: Yes, but according to the specs it is not guaranteed that the GC calls the DTor if the Object is collected. Where? This page says pretty plainly: http://dlang.org/class.html#destructors "The garbage collector calls the destructor

Re: class destruction

2015-09-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 07:19:58 UTC, Q wrote: Can I be sure that the Handle is destroyed as soon as the class is destroyed? It will do that automatically. Like the others said, you won't be sure when the class is destroyed unless you have the user code take ownership of it. (This

Re: class destruction

2015-09-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 15:10:33 UTC, Q wrote: But since D has a GC and (per default) force to heap allocate a class. So IMO the GC should also destroy it, everything else is just awkward. Well, it *does* by default. If that's what you want, just do it the plain way with simple

Re: Version for windows/console compilation?

2015-09-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 10 September 2015 at 18:06:43 UTC, Prudence wrote: Is there a flag for knowing when a project is compiling for windows(Uses WinMain) vs a console(normal main)? You'd have to choose the main yourself anyway, so document what process you use for that for people to use. BTW it is

Re: private selective import not so private ?

2015-09-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 11 September 2015 at 00:52:00 UTC, BBasile wrote: While trying to get why some call to memmove without the right import didn't lead to a compilation failure i've found that imported symbols are not private ! Is that a bug ? The specs don't say that a selective import is public !

Re: shared array?

2015-09-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 11 September 2015 at 00:48:28 UTC, Prudence wrote: static Array!(bool delegate(int, WPARAM, LPARAM)) callbacks; Try just using a regular array instead of the library Array. static bool delegate(int, WPARAM, LPARAM)[] callbacks; my guess is the Array library thing isn't marked as

Re: version and configuration

2015-09-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 12 September 2015 at 14:41:45 UTC, Spacen Jasset It appears that I can't put this in a module and import it elsewhere to test the version specifications as they are all in their own namespaces. Is this then a dead end for having a feature configuration file? Correct, version

Re: Calling D from C, C++, Python…

2015-09-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 12 September 2015 at 09:47:55 UTC, Jacob Carlborg wrote: Well, if your D function doesn't use anything of the runtime I guess it's not necessary. Right. If you don't call into the threading system in the druntime, you should be ok. Keep in mind though that the GC uses the

Re: shared array?

2015-09-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 12 September 2015 at 22:36:00 UTC, Laeeth Isharc wrote: Thank you for this. How large is the allocation for closure for a delegate? Just a pair of pointers? It depends on what the delegate needs to capture. It makes a copy of the local variables the function is referencing.

Re: shared array?

2015-09-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 12 September 2015 at 13:42:44 UTC, Prudence wrote: Using it at all is a problem because one doesn't know when and where. It is called when the collect function is called and where it was called from. D's garbage collector isn't magic, it is just a function that frees memory

Re: Calling D from C, C++, Python…

2015-09-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 12 September 2015 at 18:20:37 UTC, Brad Roberts wrote: You can get away with it in some circumstances, but it's at your own risk. Yeah, I agree.

Re: [D Cookbook]about "Communicating with external processes" part.

2015-09-13 Thread Adam D. Ruppe via Digitalmars-d-learn
I'm in a super rush, running late to something else, but try using readln in the child before writing and see what happens. You sent data to it but the child never read it.

Re: Creating a DLL with a ActiveX interface.

2015-09-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 14 September 2015 at 15:14:05 UTC, Taylor Hillegeist wrote: Gives a short example but the code doesn't compile for me. core\stdc\windows\com.d seems to be missing? I think the doc copy/pasted a typo there. It should be `core.sys.windows.com`. I've done some COM stuff with D

Re: Creating a DLL with a ActiveX interface.

2015-09-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 14 September 2015 at 15:44:36 UTC, Taylor Hillegeist wrote: So, Actually I am using NI LabVIEW to interact with my DLL. I imagine even getting hold of of that would troublesome or expensive. Ah, all right. Here's a SO thing (followed up by email then copy/pasted there) I did for

Re: Another, is it a bug?

2015-09-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 16 September 2015 at 03:48:59 UTC, Random D user Given that, normally properties are just overloaded methods in D, it's pretty sad classes break this behavior/convention. The D behavior for overloading is different in general: http://dlang.org/hijack.html It basically never

Re: Passing Arguments on in Variadic Functions

2015-09-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 14 September 2015 at 19:59:18 UTC, jmh530 wrote: In R, it is easy to have some optional inputs labeled as ... and then pass all those optional inputs in to another function. I was trying to get something similar to work in a templated D function, but I couldn't quite get the same

Re: Nested classes question?

2015-09-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 16 September 2015 at 01:12:58 UTC, Dave Akers wrote: When a program exits and D's memory management is cleaning up calling all of the ~this's is there a reason it calls the outer class's ~this before the inner class's ~this? All class destructors are called in an undefined

Re: Multiple implicit type converters

2015-09-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 11 September 2015 at 16:25:53 UTC, Bahman Movaqar wrote: As only one `alias this` is possible for any type, how should one implement multiple implicit type converters? multiple alias this is supposed to work and might some day fyi But for today, the explicit is the only way to go.

Re: shared array?

2015-09-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 11 September 2015 at 17:29:47 UTC, Prudence wrote: I don't care about "maybe" working. Since the array is hidden inside a class I can control who and how it is used and deal with the race conditions. You could use __gshared instead of shared. It means put it in non-tls storage,

Re: Multiple implicit type converters

2015-09-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 11 September 2015 at 19:51:09 UTC, Dave Akers wrote: Would it be possible to create it as an 'as' template? Yeah, the way I'd do it is something like: T as(T)() { import std.traits; static if(isIntegral!T) return to!T(convert_to_some_int); else static

Re: shared array?

2015-09-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 11 September 2015 at 20:06:53 UTC, Prudence wrote: Can you back up this claim? Not saying your lying, I'd just like to know it's true for a fact? The list of things that trigger the GC is pretty short. See the bottom of this page: http://dlang.org/garbage.html Basically, the

Re: shared array?

2015-09-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 11 September 2015 at 21:48:14 UTC, Prudence wrote: Oh really?!?! I thought slicing used the GC? Is this a recent development or always been that way? Always been that way. A D slice is just a C pointer + length packed together. A slice simply increments the pointer and/or

Re: Version for windows/console compilation?

2015-09-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 11 September 2015 at 04:30:44 UTC, Prudence wrote: I'm using Visual D and I assume it takes care of all this. It works so that's not a huge problem. If it is taking care of the linker switch, then you gain nothing but more complicated and fragile code by writing a WinMain! I was

Re: Huge output size for simple programs

2015-09-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 11 September 2015 at 11:15:33 UTC, NX wrote: hello_world (linux executable) -> 13 MB !!! Try running `strip yourexecutable` on all compilers, but on gdc it should make the biggest difference. It brings debugging info and exported symbols. Is this because whole GC implementation

Re: Hello World Example with Glade?

2015-09-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 11 September 2015 at 14:00:30 UTC, Mike McKee wrote: I finally got it to compile with your help, guys! :) Here's what I had to type: # dmd test1.d -L-ldl -I/usr/include/dmd/gtkd3 `pkg-config --cflags --libs gtkd3` Don't forget to answer yourself on SO too!

Re: Checking for Homogeneous Tuples

2015-09-15 Thread Adam D. Ruppe via Digitalmars-d-learn
If it is a tuple of values too, you could just try to form an array out of it: `static if (__traits(compiles, [your_tuple]))`. But allSatisfy might be better. For the predicate there, remember it needs to take a template argument.

Re: tkd not linking

2015-09-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 15 September 2015 at 17:37:40 UTC, karabuta wrote: Just incase, I have install version 8.6 of the Tcl/Tk libraries Did you get the development version? sudo apt-get install tk-dev or possibly sudo apt-get install tk8.6-dev should do it. I'm not actually sure if that's required

Re: Defining compile-time constants?

2015-09-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 17 September 2015 at 15:32:25 UTC, Tim K. wrote: I am wondering if there is any way to define constants to pass to the compiler like in C (especially useful in combination with Makefiles, for obvious reasons), i.e.: My preference is to make an app.config module that lists these

Re: Passing Arguments on in Variadic Functions

2015-09-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 17 September 2015 at 17:35:18 UTC, jmh530 wrote: I noticed that there's some interesting interplay with this technique and default arguments. Yeah, it expects the V... to consume the rest of the arguments so it doesn't really leave any room for the default arg. I would actually

Re: Creating a DLL with a ActiveX interface.

2015-09-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 17 September 2015 at 17:58:49 UTC, Taylor Hillegeist wrote: if anyone knows how to easily convert between the two i would be happy to know. You'll just need to write an adapter... I started a minimal one here: https://github.com/adamdruppe/com/blob/master/comhelpers.d#L123 but

Re: bug? for(int i=0;i<1;) vs while(true)

2015-09-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 17 September 2015 at 19:32:16 UTC, ddos wrote: source\app.d(72): Warning: statement is not reachable What's there? Anything after an endless loop is potentially unreachable and dub treats warnings as errors. With the for loop, the compiler can't be as sure that it is endless

Re: bug? for(int i=0;i<1;) vs while(true)

2015-09-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 17 September 2015 at 19:47:15 UTC, ddos wrote: yeah i tried for(;;) and it generates the same warning :) sure, here is the full example, it's not too long anyways ( the example doesn't make much sense tho because socket.accept is blocking :P ) http://pastebin.com/9K0wRRD6 Yeah,

Re: Why is sort allocating in this case?

2015-09-17 Thread Adam D. Ruppe via Digitalmars-d-learn
Works for me. What version are you using? Might be the old one wasn't actually marked nogc yet.

Re: shared array?

2015-09-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 11 September 2015 at 04:28:52 UTC, Prudence wrote: I thought about that but then I have to rely on the GC for some simple things. Doesn't seem like the right way to go. Since it is static, it will never be collected anyway, so you could just use it and it'll work for convenience

Re: Huge output size for simple programs

2015-09-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 11 September 2015 at 14:30:00 UTC, NX wrote: One question: Why? use the map viewer to get more info: http://thecybershadow.net/d/mapview/ use dmd -map to create the file it wants

Re: shared array?

2015-09-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 11 September 2015 at 14:47:15 UTC, Prudence wrote: If it's never collected and the GC scans it every time, it means it adds a constant overhead to the GC for absolutely no reason, right? GC overhead isn't quite constant, it happens only when you call for a collection cycle. But

Re: Compilation error

2015-09-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 15 September 2015 at 09:17:26 UTC, Loic wrote: Error: cannot find source code for runtime library file 'object.d' How did you install dmd? The installer exe or the zip both should have come with all these files packaged together.

Re: Difference between back (`) and double (") quoted strings

2015-09-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 12 September 2015 at 08:22:03 UTC, NX wrote: What if I told you, you should search the official reference before asking such things in the forum? Searching is kinda hard, so I encourage people to ask if something doesn't come up quickly. And then we need to be sure to always

Re: address of overloaded function

2015-09-30 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 30 September 2015 at 22:48:03 UTC, Freddy wrote: How do you take the address of a specific overloaded function. This won't compile You can write a helper function that uses __traits(getOverloads) and searches them for the right signature:

Re: Which GDC to download?

2015-10-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 1 October 2015 at 12:04:40 UTC, NX wrote: 1) Why there is a download targeting arm-linux-gnueabi(hf) and what exactly it means? Is this a cross-compiler which will produce obj files containing ARM instructions or what? If so, will linking just work? and how? Yes, that's a cross

Re: Regex start/end position of match?

2015-10-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 1 October 2015 at 03:29:29 UTC, Gerald wrote: I'm stuck though on how to get the start/end index of a match? I couldn't find one either so I did the pre/post/hit things broken up. Take a look at this little program I wrote: http://arsdnet.net/dcode/replacer/ All the files it

Re: help me learn to read documentation

2015-10-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 1 October 2015 at 19:15:39 UTC, Robin wrote: The documentation here (http://dgame-dev.de/index.php?controller=learn=package=graphic=Text=0.6)... gives me the Text() class but i dont know how to use "foreground, background, and Font mode" or at least turn it into usable syntax.

Re: How to break gdb on D exception ?

2015-10-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 2 October 2015 at 03:58:45 UTC, BBasile wrote: none of the following GB commands work: give break d_throw or maybe `break d_throwc` a try

Re: Server side command execution.

2015-09-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 28 September 2015 at 11:44:32 UTC, holo wrote: if(to!string(buffer[0..received]) == "exit\n") You shouldn't need that to!string by the way. I believe that will work just comparing the buffer directly. Converting to string is more important when you are storing a copy than just

Re: char[] ported from C to char[0] in the D core library

2015-09-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 16:49:39 UTC, badlink wrote: The struct core.sys.linux.sys.inotify.inotify_event contains the field "char[0] name" which corresponds to "char name[]" in C. Why it has been translated to "char[0]" ? In that structure, the name is appended directly to the end

Re: OSX prompt limit

2015-09-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 01:35:26 UTC, Joel wrote: auto line = terminal.getline("your prompt: "); Huh, that should work unless your terminal is outrageously narrow or maybe output starting on the right side of the screen already. But I can't look much further without having a

Re: OSX prompt limit

2015-09-09 Thread Adam D. Ruppe via Digitalmars-d-learn
Maybe you can try gnu readline instead: extern(C) char* readline(const(char)* prompt); pragma(lib, "readline"); pragma(lib, "curses"); void main() { auto line = readline("your line: "); import std.stdio, std.conv; writeln(to!string(line)); }

Re: OSX prompt limit

2015-09-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 21:27:05 UTC, Joel wrote: Thanks Adam. That works better than normal. Up and down don't work though. There's another function called add_history for that. Readline is a pretty popular library (also GPL though, keep that in mind if you distribute your

Re: implementing Ketmar's concept of a debugging console in D (Lua/PyD + arsd terminal-emulator)

2015-10-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 5 October 2015 at 19:57:21 UTC, Laeeth Isharc wrote: Adam's work on terminal is quite nice - runs on Linux and Windows (maybe OSX) and it has mouse support and you can display images inline, which can be useful for some purposes. Command history and easy to add shortcuts. The

Re: This is probably trivial or impossible Code Introspection...

2015-09-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 19 September 2015 at 19:52:56 UTC, WhatMeWorry wrote: So I've got type and value of each member, but I want their actual names? http://dlang.org/phobos/std_traits.html#FieldNameTuple You can also do something like `foo.tupleof[idx]["foo.".length .. $]` for an individual thing

Re: How can a value of a constant be varied through a pointer ?

2015-09-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 20 September 2015 at 00:09:52 UTC, RADHA GOGIA wrote: I went through these two links and found that this behaviour is undefined , but the only issue which I have is that in one sense we say that since local variables live on stack , hence they cannot be located on read only memory

Re: scope in function argument

2015-09-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 23 September 2015 at 17:09:40 UTC, Freddy wrote: What does it mean when there is a scope in a function argument. That you are not supposed to let that reference escape the function scope. The compiler does little verification of this right now, but may optimize on that

Re: Dub package with C code

2015-09-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 24 September 2015 at 06:21:02 UTC, Sebastiaan Koppe wrote: Because I want to focus on the product I am building right now, not on side-projects. We should write a C to D converter. We have htod but I'm talking the whole source of it. That might be useful for times like this.

Re: What's wrong with this code?

2015-09-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 19 September 2015 at 02:30:39 UTC, Chris wrote: bmove.addOnClicked (delegate void (Button aux) { What's the context of this call? If it is inside a struct and you are accessing local variables you can get in trouble because the context pointer may not be

Re: Why are static arrays not ranges?

2015-09-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 21 September 2015 at 20:33:10 UTC, Jack Stouffer wrote: pragma(msg, isInputRange!(typeof(a))); try: pragma(msg, isInputRange!(typeof(a[]))); Notice the addition of the [] after the a. That's the slicing operator and it will yield a range. Is there an actual reason for

Re: What difference between std.typecons.Tuple and std.meta.AliasSeq

2015-09-20 Thread Adam D. Ruppe via Digitalmars-d-learn
AliasSeq is just a random collection of stuff. A Tuple is more like a struct.

Re: Question about Object.destroy

2015-09-20 Thread Adam D. Ruppe via Digitalmars-d-learn
Very simple: destroy(s) (or s.destroy but i prefer destroy(s)) will set the reference it is passed to null because you aren't supposed to use it anymore. So after calling destroy(s), s is null, so it segfaults when you try to use it.

Re: Question about Object.destroy

2015-09-20 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 20 September 2015 at 18:34:37 UTC, Lambert Duijst wrote: Oh that surprises me a bit, because I read in the list of deprecated features that delete is deprecated and that the right thing to do is to use destroy instead. Right. One of the benefits of destroy is that it nulls the

Re: Question about Object.destroy

2015-09-20 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 20 September 2015 at 18:41:18 UTC, anonymous wrote: But that doesn't change either. I think Adam is mistaken here. huh, I just checked the source... and you are right, it doesn't set classes to null itself, but does null out the vtable inside. *ppv = null; // zero vptr

Re: Question about Object.destroy

2015-09-20 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 20 September 2015 at 18:52:17 UTC, Lambert Duijst wrote: Just want to know if D protects against dangling pointers or is this just something you should never do. The answer is both: it tries to protect you but you still shouldn't do it. If we are not supposed to use

Re: Why is the constructor of B called?

2015-09-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 23 September 2015 at 21:08:37 UTC, tcak wrote: I wouldn't expect B's constructor to be called at all unless "super" is used there. "If no call to constructors via this or super appear in a constructor, and the base class has a constructor, a call to super() is inserted at the

Re: Dub package with C code

2015-09-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 25 September 2015 at 14:15:20 UTC, bachmeier wrote: On Friday, 25 September 2015 at 12:25:52 UTC, tired_eyes wrote: Once again, I'm absolutely sure tha D should have an official blog! Forums can't replace blogs, forums are for discussions, not for content presentation. I've long

Re: How to get the current Timezone

2015-08-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 28 August 2015 at 17:59:06 UTC, WhatMeWorry wrote: Stupid question. If it always returns an empty string, why is it even there? It can return meaningful information in other subclasses; it is a method from the interface and is just blank in the LocalTime class. If you construct

Re: Using phobos as shared library for multiple binaries

2015-12-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 5 December 2015 at 21:49:52 UTC, Ralf wrote: I've written several small command-line utilities in D that are to be shipped together in one package. I'm not sure if shared lib support is on Mac or not (I know it is on Linux but mac is different...). But do they need to actually

Re: using parse with string slice

2015-12-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 5 December 2015 at 22:05:11 UTC, anonymous wrote: You can use std.conv.to instead or assign the slice to a variable first. This is a bit of a FAQ I think because people don't realize you can use to and parse to do the same thing. The big difference is parse will advance the

Re: Reset all Members of a Aggregate Instance

2015-12-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 3 December 2015 at 21:04:00 UTC, Nordlöw wrote: is there a generic way, perhaps through reflection, to reset (inside f) all members of `c` to their default values? You could always copy the init back over it. For a struct: s = Struct.init; for a class... well, the code is a lot

Re: Testing if a file is connected to a terminal

2015-12-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 17 December 2015 at 03:59:27 UTC, Jakob Ovrum wrote: There are some terminal libraries on Github (like consoled) but I have to say I think they're uninspiring in terms of quality and presentation. Can you be any more specific about that?

Re: Why should file names intended for executables be valid identifiers?

2015-12-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 15 December 2015 at 03:31:18 UTC, Shriramana Sharma wrote: I understand that module names need to be valid identifiers in that other modules would need to import them. But when a file is intended to be just an executable, why is it mandatory to give it a module declaration with a

Re: Inferring an integer literal as ubyte

2015-12-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 14 December 2015 at 13:33:41 UTC, Shriramana Sharma wrote: ubyte code = to!ubyte(spec, 6) + 16; That's not an integer literal... that's a runtime value of ubyte plus an integer literal. Since the ubyte is the result of a runtime function, the compiler doesn't know what it will

Re: D programming video tutorial

2015-12-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 13 December 2015 at 20:29:47 UTC, Pederator wrote: Does anybody who is familair with D consider to make a comprehensive D programming video tutorial / training / course? I've hired someone out of my own pocket to work on it, with me there to answer questions and review content for

Re: Why should file names intended for executables be valid identifiers?

2015-12-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 17 December 2015 at 04:26:04 UTC, Shriramana Sharma wrote: Sorry but I don't get this fully: can't a hyphen be part of such mangled names? I'm actually not sure but I have never seen it done. And any reflection of the module name would also be just a string which need not be a

Re: Testing if a file is connected to a terminal

2015-12-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 17 December 2015 at 05:01:15 UTC, Jakob Ovrum wrote: Where's the reference documentation? In the source... but yeah, good point. I'm working on writing docs for a lot of my stuff. Terminal is still completely messed up http://arsdnet.net/arsd/terminal.html cgi is meh but

Re: No documentation for core.sys?

2015-12-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 17 December 2015 at 03:40:02 UTC, Shriramana Sharma wrote: Why isn't there a documentation page http://dlang.org/phobos/core_sys.html whereas lots of other core.* modules are documented? Because the D build process is f***ed up and the website build process is yet another layer

Re: Integer literals

2016-01-04 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 4 January 2016 at 14:54:29 UTC, ric maicle wrote: 0U .. 4_294_967_296U in the table Decimal Literal Types has a typo. Shouldn't the range end with 4_294_967_295U? The x .. y syntax excludes y. So 0..3 covers 0, 1, 2. It excludes 3.

Re: Size of Compiled Program

2016-01-04 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 4 January 2016 at 13:49:03 UTC, Martin Tschierschke wrote: When I was writing a small speed test - D versus Ruby The smallest possible ruby program has about ~5 MB of dependencies, outside the operating system (the ruby runtime itself). The D program has none. It carries its

Re: virtual destructor in C++ integration: bug or me being stupid?

2015-12-29 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 29 December 2015 at 18:32:23 UTC, Atila Neves wrote: The problem here is that I don't know what the workaround is. The one I used (well, last time I tried this) was to just put a dummy function in the D interface that is a placeholder for it. interface C++Class { // at the

Re: Can't find windows' CreateThread function / concurrency.spawn crashes host application

2016-01-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 1 January 2016 at 22:02:46 UTC, alkololl wrote: I've found that std.c.windows.windows doesn't include a std.c.windows is basically useless. The new version should have it in core.sys.windows.windows though I'm not sure if it has actually been released yet. If it isn't in there

Re: Can't find windows' CreateThread function / concurrency.spawn crashes host application

2016-01-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 2 January 2016 at 00:32:20 UTC, alkololl wrote: Why is that? I'm not sure, but in the switch you posted, you didn't handle the DLL_THREAD_ATTACH and DLL_THREAD_DETACH cases, the runtime might be incrementing the refcount there. Check this out:

Re: link to C function whose name is a D keyword

2016-01-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 6 January 2016 at 15:41:27 UTC, Carl Sturtivant wrote: //D that doesn't work: extern(C) int try(int x); Try: pragma(mangle, "try") extern(C) int try_(int x); then call it with the udnerscore in D, the linker should tie it up thanks to the pragma.

Re: Calling functions from other files/modules

2016-01-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 6 January 2016 at 22:06:32 UTC, Namal wrote: Do I have always to include std.stdio in every file like in the example or is it enough just to import a module which has this already included? In every file that you use it, yes. Module imports are private to the module (well,

Re: kernel32 missing symbol definitions?

2016-01-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 8 January 2016 at 00:27:51 UTC, Yamiez wrote: Why is kernel32 missing symbols? e.g CreateProcess, CreateToolhelp32Snapshot and alot more :/ The kernel32 lib has them, the headers don't. You can define the missing functions yourselves and call them: --- import

Re: SIGSEGV in invariant._d_invariant(Object)

2016-01-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 6 January 2016 at 21:50:23 UTC, Keywan Ghadami wrote: how to fix an SIGSEGV in invariant._d_invariant(Object)? That means you are calling a method on a null object. Your object might be at the bottom of the stack trace listing. Check your code for a declared class that you

Re: Calling functions from other files/modules

2016-01-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 6 January 2016 at 23:00:43 UTC, Namal wrote: I just tried to import one module with a main into another, but I get this: You can't have two mains, but you can import a module with main from another module without one.

Re: Unexpected ' ' when converting from type string to type int

2015-12-29 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 30 December 2015 at 01:36:56 UTC, Michael S wrote: auto matrix_size = readln; Change that to auto matrix_size = readln.strip; and you should be in business. readln() returns any leading spaces and the newline character at the end of the line too, which is why to is

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