Re: Get and set terminal size

2014-04-19 Thread Adam D. Ruppe via Digitalmars-d-learn
Blargh, I don't know teh ldc switch for it :( Try adding pragma(lib, curses); (or ncurses) to your file with main in it, i think ldc supports that.

Re: toString() through interface

2014-04-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 20 April 2014 at 00:35:30 UTC, David Held wrote: Since all implementations of an interface must derive from Object That's not true. They can also come from IUnknown or a C++ interface. cast(Object)(foo).toString(); (cast(Object)foo).toString() might work This might

Re: Writing to stdin of a process

2014-04-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 26 April 2014 at 08:45:59 UTC, Craig Dillabaugh wrote: Can anyone tell me what I am dong wrong. In this case, I'd close the pipe when you're done. pipes.stdin().writeln(Hello world); pipes.stdin.close; myecho loops on stdin until it receives everything; until the pipe

Re: Socket server + thread: cpu usage

2014-04-29 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 29 April 2014 at 17:16:33 UTC, Tim wrote: Is there anything I'm doing wrong? You should be using a blocking socket. With them, the operating system will put your thread on hold until a new connection comes in. Without them, it will endlessly loop doing absolutely nothing except

Re: Socket server + thread: cpu usage

2014-05-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 1 May 2014 at 08:08:37 UTC, Tim wrote: ... the CPU usage goes up. I think that SocketShutdown.BOTH causes Socket.select to fail which results in an endless loop. Any suggestions how to handle that problem? It shouldn't be here, disconnect would affect the new socket, and you're

Re: Decoding HTML escape sequences

2014-05-12 Thread Adam D. Ruppe via Digitalmars-d-learn
You should use decodeComponent instead of decode in your matchAll loop. IMO encodeComponent and decodeComponent are the only two useful uri encode functions (btw same in JS, use decodeURIComponent instead of the other functions). The other ones have weird rules.

Re: Can't call isDir on linux on const object

2014-05-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 19 May 2014 at 20:11:45 UTC, Spacen wrote: The same code works on windows DMD 1.65. But on linux: It's because of caching. isDir on Linux calls a function with this comment: /++ This is to support lazy evaluation, because doing stat's is

Re: [std.c.stdlib] (malloc(something) is null) or (malloc(something) == 0)?

2014-05-20 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 20 May 2014 at 14:03:17 UTC, Alexandr Druzhinin wrote: if(data ?) // is null vs == 0 Both would work and do the same thing, but I prefer is null because that is most consistent with other D code (where there might be a difference between the two).

Re: How to get struct's members ?

2014-05-22 Thread Adam D. Ruppe via Digitalmars-d-learn
allMembers yields the names of all the members. Try .tupleof on an object instead, that might work better.

Re: Building and using a function library

2014-05-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 25 May 2014 at 19:07:10 UTC, Charles Parker wrote: ./min_cut.d(15): Error: module line_count from file ../my_utils/line_count.d must be imported as module 'line_count' That means you forgot the module line in line_count.d At the top of that file, add: module my_utils.line_count;

Re: Looping over all enum values

2014-05-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 28 May 2014 at 20:19:45 UTC, Mark Isaacson wrote: Is there a mechanism that allows you to loop over all of an enum's values? I've wanted to do so a couple times now for CTFE/mixin templates. __traits(allMembers) on the enum can do it or this can help too

Re: Read file on compiler time.

2014-05-29 Thread Adam D. Ruppe via Digitalmars-d-learn
string a = import(file.txt); dmd yourprogram.d -Jlocation_of_file so for example dmd yourprogram.d -J. if file.txt is in the same directory as the .d file.

Re: Read file on compiler time.

2014-05-29 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 29 May 2014 at 20:38:30 UTC, Remo wrote: Now another question is it also possible to save/write string at compile time? Sort of, use pragma(msg, some string); and it will be printed out when that code is compiled. Important that it is when the code is compiled, NOT when the

Re: Kernel in D

2014-05-31 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 31 May 2014 at 07:28:32 UTC, Mineko wrote: Any ideas? :P Buy my book, chapter 11 talks about it a little to get you started :P http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book The summary of my approach there is: 1) Use a regular linux compiler

Re: Forward reference to nested function not allowed?

2014-05-31 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 31 May 2014 at 16:18:35 UTC, DLearner wrote: Is this intended? Yes, nested functions access local variables and thus follow the same order of declaration rules as they do; you can't use a local variable before it is declared so same with a nested function.

Re: Kernel in D

2014-05-31 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 31 May 2014 at 22:54:48 UTC, Qox wrote: scope(exit) foo(); uses exception handling in the background. That just works with dmd even in the bare metal environmnet. Throwing an exception needs library support with dmd but you can copy/paste it from druntime - I did that in my

Re: Separate allocation and construction?

2014-06-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 5 June 2014 at 22:22:16 UTC, Chris Williams wrote: If I wanted to allocate memory for a class and then call its constructor as two separate steps, while still having the object be managed by the garbage collector, is there any way to do that? Check out std.conv.emplace

Re: Can't link libs?

2014-06-06 Thread Adam D. Ruppe via Digitalmars-d-learn
When you compile the final program, the library .d file needs to be available too, either in the folder based on its name or passed straight to dmd explicitly. Despite the presence of the .lib file, the .d file is still needed so it can get code prototypes and type names, etc., out of it.

Re: Can't link libs?

2014-06-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 6 June 2014 at 16:41:24 UTC, K.K. wrote: I have kept all the files in one folder. So if I don't need to explicitly call the .lib in DMD, does that mean the .lib is just a passive object? Should I make libs in place of object files? If you pass all the .d files at once, you don't

Re: Can't link libs?

2014-06-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 6 June 2014 at 17:02:33 UTC, K.K. wrote: Oh okay, I get what you mean. I guess I was really over complicating it then? xD Yea, I think a lot of people do: building C++ takes some extra steps out of necessity that you can just ignore in D for the most part :) Thanks for the help

Re: Windows DLL / Windows service

2014-06-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 7 June 2014 at 14:41:15 UTC, Etienne Cimon wrote: no documentation though. Any idea how to attach/detach with a known example? I'd also like to create a windows DLL that compiles through DMD/GDC/LDC with extern(c) so that folks from C++ can link with it . Check this out:

Re: Running a delegate inside a C function

2014-06-07 Thread Adam D. Ruppe via Digitalmars-d-learn
See my answer to this: http://stackoverflow.com/questions/22845175/pass-delegates-to-external-c-functions-in-d Since a delegate is two pointers and most C functions expect only one pointer, you need to do some kind of magic. There's one solution. Another is if the C function can pass a void*

Re: Class Data Members Name Reflection

2014-06-10 Thread Adam D. Ruppe via Digitalmars-d-learn
Two options: do allMembers and filter it out to only be data members, or do some slicing of tupleof.stringof: S s; foreach(idx, member; s.tupleof) { writeln(Name: , s.tupleof[idx].stringof[2..$]); } The tupleof[idx] inside the loop is important instead of just using member because then

Re: Class Data Members Name Reflection

2014-06-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 10 June 2014 at 16:30:52 UTC, Nordlöw wrote: What trait should I use to filter out data members? No trait, more like an is thing to see if the thing has an init. I think static if(is(typeof(__traits(getMember, Thing, name).init)) { } will do it. (BTW the sample chapter of my

Re: Basics of calling C from D

2014-06-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 11 June 2014 at 13:52:09 UTC, belkin wrote: Question: How do I use it from D? Write the prototype in your D file with extern(C): extern(C) int factorial(int n); then just call the function normally in D. Make sure you include all the C object files when you compile the D

Re: Basics of calling C from D

2014-06-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 11 June 2014 at 14:11:04 UTC, simendsjo wrote: I believe the correct answer should be Buy my book!. ah, of course! I should just make a .sig file lol http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book chapter 4 talks about this kind of thing :P

Re: modulo Strangeness?

2014-06-11 Thread Adam D. Ruppe via Digitalmars-d-learn
modulo of a negative number can give some surprising results. A negative index in that array would cause it to throw a range error, so my guess is that's what you're getting. If you do %array.length though it becomes an unsigned math and thus will never be negative, explaining the different

Re: Basics of calling C from D

2014-06-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 11 June 2014 at 14:45:22 UTC, simendsjo wrote: I must say I really like your writing-style as well as the down-to-earth and precise and concise presentation of the material. So kudos to you! thanks, don't forget to tell that to amazon review readers too :P Really looking

Re: Nameless Static Array

2014-06-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 12 June 2014 at 15:58:25 UTC, Taylor Hillegeist wrote: But without the NEW strategy. I must allocate static arrays and set them to a pointer in my struct. Not too big of deal really. Have you considered just making the buffer a struct member?

Re: Nameless Static Array

2014-06-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 12 June 2014 at 16:08:49 UTC, Taylor Hillegeist wrote: I am considering having different sized arrays for the buffer. I just figured that meant having different structs with various sizes. You might be able to do it with a templated struct and alias this. Check this out:

Re: Cannot alias null

2014-06-12 Thread Adam D. Ruppe via Digitalmars-d-learn
since null is a value maybe you want enum blah = null; you may also give it a type after the enum word

Re: Regarding DConf 2014

2014-06-15 Thread Adam D. Ruppe via Digitalmars-d-learn
The videos are being posted at a rate of about two per week. So far talks 1-5 are up plus Scott Meyer's talk, you can find the links in the announce group. http://forum.dlang.org/group/digitalmars.D.announce

Re: Struct Constructors

2014-06-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 16 June 2014 at 22:03:28 UTC, Mark Blume wrote: Why exactly isn't a constructor without any parameters is not allowed? The idea is that declaring a plain struct always has almost zero cost - it is just static data with no extra code run. A zero-arg constructor (aka a default

Re: std.algorithm.map - function by reference

2014-06-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 24 June 2014 at 21:46:16 UTC, kuba wrote: The main point here is to avoid unnecessary copies You should make sure this actually matters - passing doubles by ref for example is probably slower than just passing a regular double.

Re: What is best way to communicate between computer in local network ?

2014-06-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 27 June 2014 at 12:51:45 UTC, bioinfornatics wrote: I do not know if that is better to use websocket and if they exists into dlang: you could use websocket in D but if you are talking between two separate D programs you can just use a regular socket

Re: Why is the Win32 boilerplate the way it is?

2014-06-30 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 30 June 2014 at 15:14:24 UTC, Jeremy Sorensen wrote: documentation means import core.sys.windows.windwos The Windows headers that come with D are pathetically minimal. You'll need to grab a more complete win32 header OR copy/paste the individual prototypes off MSDN and use them

Re: File needs to be closed on Windows but not on Posix, bug?

2014-07-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 5 July 2014 at 20:23:03 UTC, Joakim wrote: This seems like inconsistent behavior: should I file a bug? This is because the operating systems do it differently; I think D is doing the right thing by being a pretty thin wrapper around that functionality. If anything, I'd just

Re: Using a delegate when interfacing with C

2014-07-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 5 July 2014 at 22:18:56 UTC, Marco Cosentino wrote: auto client = *(cast(ClientImplementation*) data); Try just auto client = cast(ClientImplementation) data; and this.setProcessCallback(callback, cast(void *) this); setProcessCallback(callback, cast(void*) this);

Re: Introspecting a Module with Traits, allMembers

2014-07-10 Thread Adam D. Ruppe via Digitalmars-d-learn
The others have already given some answers, I just want to point out that the (free) sample chapter of my D book covers this topic too: http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book Scanning a whole module and getting everything out takes a few tricks that I

Re: Question about @nogc in D 2.066

2014-07-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 11 July 2014 at 20:02:32 UTC, Weasel wrote: Why does the s1 not throw an error, but the a1 does? Strings don't allocate upon use whereas all other arrays do unless you specifically mark it as static - immutability isn't considered here (I think because the part of the compiler

Re: reference to delegates and garbage collection

2014-07-14 Thread Adam D. Ruppe via Digitalmars-d-learn
I'm just guessing, but it looks to me that the delegate's pointer might be on the stack there and isn't overwritten when the one function returns, so the gc still thinks there might be an active pointer to it.

Re: is there a way to pause a program and resume with just a key press (or enter key)

2014-07-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 15 July 2014 at 02:49:56 UTC, WhatMeWorry wrote: Is there a way to continue with any old key press? or just the enter key? Yeah. It is more complex than you'd think but my terminal library can do it: https://github.com/adamdruppe/arsd/blob/master/terminal.d Example usage:

Re: Problem with trying sample from doc page

2014-07-16 Thread Adam D. Ruppe via Digitalmars-d-learn
I would just change all the longs to ints and it would probably work. Or all the longs to ints. It really should have been consistent in the docs, since the point of this is delegate vs function, not int vs long...

Re: Converting a POD struct to a class at compile-time ?

2014-07-16 Thread Adam D. Ruppe via Digitalmars-d-learn
Not a direct answer, but the way I'd do this is to just use composition: class Foo { YourStruct _this; alias _this this; } boom, it'd work pretty well just like that...

Re: Converting a POD struct to a class at compile-time ?

2014-07-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 16 July 2014 at 17:43:03 UTC, Klb wrote: auto names = __traits(allMembers, S); Error: static variable _names_field_0 cannot be read at compile time. The problem there is names is a regular runtime variable and mixins need to use compile time stuff. If you make that enum

Re: Grabing C(++) stdout

2014-07-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 23 July 2014 at 15:30:53 UTC, Chris wrote: Redirect it from stdout to somewhere else. It might be writing to stderr instead of stdout... does anything change if you reopen stderr too?

Re: zlibs gzip dosent work with http

2014-07-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 24 July 2014 at 13:09:53 UTC, Sean Campbell wrote: I'm trying to add gzip compression to a HTTP server i wrote in D. here is the code that dose the gzip encoding. I know zlib gzip works for http, I used it in my cgi.d if(gzipResponse acceptsGzip isAll) {

Re: D JSON (WAT?!)

2014-07-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 24 July 2014 at 15:15:37 UTC, Pavel wrote: string s = parsed[fail].str; Since there is no entry fail in the object, it returns a null JSON_VALUE pointer. Trying to get the string out of it is then seen as a null pointer access and kills the program. Check for null on a key

Re: Manually allocated structs

2014-07-27 Thread Adam D. Ruppe via Digitalmars-d-learn
I would do it something like this: struct test { size_t size; @property char[] buf() { return (_buf.ptr)[0 .. size]; } private char[0] _buf; } The buf property returns a slice that uses the size member to give you bounds checking, but uses the

Re: Are there desktop appications being developed in D currently?

2014-08-10 Thread Adam D. Ruppe via Digitalmars-d-learn
I wrote a terminal emulator in D a while ago https://github.com/adamdruppe/terminal-emulator terminal emulators are pretty boring as far as desktop applications go though. I have more on my to do list but haven't actually gotten to them yet.

Re: Are there desktop appications being developed in D currently?

2014-08-10 Thread Adam D. Ruppe via Digitalmars-d-learn
My thing works on Windows and Linux btw, though the windows version pipes to the plink program to talk to ssh. It'd be pretty easy to make it a stand alone thing though with a few tweaks, then it could be like an escape sequence handling library.

Re: Are there desktop appications being developed in D currently?

2014-08-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 10 August 2014 at 14:28:33 UTC, Puming wrote: What do you mean by 'boring'? I think a shell in D would be awesome. tbh I think shells are a bit boring too, but like you said in the other message, they are two different things. But a terminal emulator isn't much of a gui because

Re: RAII limitations in D?

2014-08-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 22 August 2014 at 02:22:16 UTC, Timothee Cour via Digitalmars-d-learn wrote: What would be a good answer to this article? It's own publication date: Feb 2009. The D struct has changed a lot since then, getting new features (@disable, postblit, more reliable destructor) and bugs

Re: How to compare two types?

2014-08-31 Thread Adam D. Ruppe via Digitalmars-d-learn
There's two ways: static if(is(One == Two)) { } That compares the static types in a form of conditional compilation. http://dlang.org/expression.html#IsExpression If you want to compare the runtime type of a class object, you can do: if(typeid(obj_one) == typeid(obj_two)) that should

Re: How to compare two types?

2014-08-31 Thread Adam D. Ruppe via Digitalmars-d-learn
typeof() always gets the static type, typeid() is needed if you want the dynamic type.

Re: How to compare two types?

2014-08-31 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 31 August 2014 at 23:53:31 UTC, bearophile wrote: if (is(typeof(obj_one) == typeof(obj_two))) You could, but since it is static info you might as well use static if.

Re: Downloading Files in D

2014-09-10 Thread Adam D. Ruppe via Digitalmars-d-learn
The curl one should be easiest for just downloading files. The big problems with it are that it can be a pain to get the library working with versioning and stuff and that it sometimes does the wrong thing in advanced use cases. But if the curl library works for you at all, doing downloading

Re: when should I use a function call without parenteses?

2014-09-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 16 September 2014 at 01:11:49 UTC, AsmMan wrote: In which context do you use a function call without paranteses? It is really just personal preference, people tend to leave the parens off when they just add subjective noise. A good rule though would be to leave the parens off

Re: Function Pointers with Type T

2014-09-15 Thread Adam D. Ruppe via Digitalmars-d-learn
You can get the code to compile with two changes: bool function(T)(T val1,T val2) ptr=comp; should be: bool function(T val1,T val2) ptr=comp!T; The function pointer itself isn't a template, so it doesn't need the (T) parameter. Instead, since it is inside a template, you can just use the

Re: Why if(__ctfe)?

2014-09-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 16 September 2014 at 13:11:50 UTC, Ilya Yaroshenko wrote: Why not static if(__ctfe) ? ctfe is a runtime condition. The function has the same code when run at compile time, it is just being run in a different environment.

Re: Function Pointers with Type T

2014-09-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 16 September 2014 at 17:32:02 UTC, amparacha wrote: Thanks Adam you saved me from alot.Just one more question how can I compare two arguments of type T. If you want to compare the values, just use them like regular variables. If you want to compare the types, use: static

Re: Unicode arithmetic at run-time

2014-09-20 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 21 September 2014 at 03:00:34 UTC, Charles McAnany wrote: writefln(%c, '/U0001F0A1'+1); // The problem here is just that arithmetic converts everything back to integers and writefln is a bit picky about types. You can print it though by casting it back to dchar:

Re: sign oauth request

2014-09-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 25 September 2014 at 17:03:43 UTC, John Chapman wrote: http://dlang.org/phobos/std_digest_sha.html#SHA1 Not quite the same, the oauth requires hmac. When I did this in my oauth.d for twitter and stuff, I used the C library mhash check out my code:

Re: What is a sink delegate?

2014-09-30 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 30 September 2014 at 17:22:44 UTC, Gary Willoughby wrote: What is a sink delegate? Instead of string toString() { return foo; } for example, you would use: void toString(void delegate(string) sink) { sink(foo); } The sink argument there is then free to view and discard the data

Re: cgi.d - fastcgi - how am i suppose to link in libfcgi.a or libfcgi.lib

2014-10-01 Thread Adam D. Ruppe via Digitalmars-d-learn
Try linking in these .obj files that I compiled for windows a while ago: http://arsdnet.net/dcode/fcgi_win.zip so unzip that, put it in your project directory and just add both .obj files to your compile command line along with -version=fastcgi. It has been a LONG time since I used that,

Re: cgi.d - fastcgi - LightTPD is not cooperative

2014-10-02 Thread Adam D. Ruppe via Digitalmars-d-learn
Try running the program yourself with a port argument yourprogram.exe --port 3000 for example, then have lighttpd configured to connect to that port for the application. That's what I had to do for nginx on Windows, lighttpd might be the same thing.

Re: cgi.d - fastcgi - LightTPD is not cooperative

2014-10-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 2 October 2014 at 13:53:48 UTC, Sycam_Inc wrote: when running in the browser the page just continues to load and the lighttpd console shows no output from it and it dosent write anything in the file. What url did you use in the browser and what's your lighttpd config look like?

Re: How do I check if a function got CTFE?

2014-10-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 2 October 2014 at 17:56:29 UTC, AsmMan wrote: I'd like to check if a function got CTFE, ie, the compiler was able to replace my foo(s); by the computed value at compile-time. You have to explicitly force ctfe with context, it is never done automatically, and if it fails, the

Re: cgi.d - fastcgi - LightTPD is not cooperative

2014-10-03 Thread Adam D. Ruppe via Digitalmars-d-learn
Hmm, I don't know and don't have it set up on windows to try right now. My suggestion is to look for getting it to work with C or C++ - since my cgi.d lib uses a C library, it should work exactly the same way in terms of configuration.

Re: 'write' crashes without extra window

2014-10-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 7 October 2014 at 23:41:14 UTC, Joel wrote: it had been opening with a command prompt, so I got rid of the prompt and now it some times crashes. That's a feature - writing to a non-existent handle fails, so it throws an exception. (The reason you don't notice this in something

Re: The module declaration is being ignored

2014-10-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wed, Oct 08, 2014 at 06:39:26PM +, Diffuse via Digitalmars-d-learn wrote: Everything works fine. But things also compile if I declare file2's module to be module candyfloss while still importing file2 within main.d You should always import the same thing as the module, but you also need

Re: Simple import question

2014-10-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 9 October 2014 at 18:21:32 UTC, WhatMeWorry wrote: To import one module from another, specify the name of the module in an import declaration. The name must include the relative path computed from the directory where compilation takes place This is not true. It is a REALLY

Re: When betterC triggers errors in compilation?

2014-10-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 14 October 2014 at 13:20:50 UTC, eles wrote: http://forum.dlang.org/post/lddug4$jgv$1...@digitalmars.com That was just a speculative thread, that stuff isn't implemented. (And I think that went way too far, IMO betterC should just remove the mandatory stuff like ModuleInfo and

Re: Mixin template functions are ignored in struct

2014-10-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 14 October 2014 at 20:58:19 UTC, tcak wrote: So, thus this mean overloading is not supported with mixin templates? Nope, what happens is mixin stuff adds items by name. If you have a variable or function in the object with the same name, it overrides the mixin one entirely.

Re: Mixin template functions are ignored in struct

2014-10-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 14 October 2014 at 21:21:33 UTC, tcak wrote: Anyway, that suggested usage is making my work harder. I am putting that mixin in many struct and defining each method one by one in that way doesn't seem like suitable to me. You could rename the method in the struct then mixin the

Re: Why was scope for allocating classes on the stack marked for deprecation?

2014-10-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 17 October 2014 at 16:56:50 UTC, Jeremy DeHaan wrote: I'm curious as to why using scope to allocate classes on the stack was marked for future deprecation. It was never implemented correctly (it is supposed prove it never leaves the scope, and is thus safe to be on the stack), so

Re: Initializing D in C to use?

2014-10-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 17 October 2014 at 16:35:46 UTC, Jeremy DeHaan wrote: I remember reading something(but my googlefu is weak today) about having to initialize the runtime if you are using D inside another language. Can anyone confirm this is the case? Yeah, unless the main() is in D, you need to run

Re: Initializing D in C to use?

2014-10-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 17 October 2014 at 17:14:30 UTC, K.K. wrote: Sorry if this isn't the most helpful answer but.. Do you have Adam Ruppe's book? buy my book too, and write amazon reviews :P A lot of the topics in there were chosen because there are questions that come up somewhat often on this forum

Re: Generating code based on UDA

2014-10-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 25 October 2014 at 13:37:56 UTC, Rares Pop wrote: Aiming to generate code based on UDA I wonder if the following is possible: Yes, and copy/pasting that works for me...

Re: Generating code based on UDA

2014-10-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 25 October 2014 at 13:45:29 UTC, Rares Pop wrote: What do you mean by copy/pasting ? I literally copied the code in your post (and fixed a missing semicolon) and got it to compile. Passing A as an argument to injections should work. You can also use this and typeof(this)

Re: HTML Parsing lib

2014-10-25 Thread Adam D. Ruppe via Digitalmars-d-learn
Another option for html is my dom.d https://github.com/adamdruppe/arsd get dom.d and characterencodings.d in your project directory. compile with dmd yourfile.d dom.d characterencodings.d here's an example: import arsd.dom; void main() { auto document = new Document(); // The example

Re: Dart bindings for D?

2014-10-29 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 29 October 2014 at 22:12:32 UTC, Laeeth Isharc wrote: I will have a crack at starting this unless anyone knows of any already in existence. I haven't heard of any. Rationale for using Dart in combination with D is that I am not thrilled about learning or writing in Javascript,

Re: Dart bindings for D?

2014-10-29 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 29 October 2014 at 22:22:39 UTC, ketmar via Digitalmars-d-learn wrote: it's not lightning fast, though, but the code is understandable and it's fairly easy to extend the language if necessary. Curious, what have you tried with it? I wanted to keep it simple but actually

Re: Pointer to constructor

2014-10-29 Thread Adam D. Ruppe via Digitalmars-d-learn
You can access constructors just like any other method if you use the __ctor name. So like MyClass.__ctor.

Re: Dart bindings for D?

2014-10-30 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 30 October 2014 at 10:18:40 UTC, Suliman wrote: No! I mean not translation to js. I mean theoretical ability of creation new programming language that can work every where! The problem is getting new features into the browsers that people use. You could also just write native

Re: Dart bindings for D?

2014-10-30 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 30 October 2014 at 06:14:18 UTC, Suliman wrote: Is it's possible to create single language that cover desktop and web? Like D+Dart? You can also run D code on the web server and do very little on the web client itself for a lot of programs.

Re: Dart bindings for D?

2014-10-31 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 30 October 2014 at 02:27:58 UTC, ketmar via Digitalmars-d-learn wrote: it was very funny to show some people D code with your jsvar and listenting how they don't want to learn just another scripting language. and then compile the code with DMD to confuse them even more. hehe, that

Re: string, char[], overloaded functions.

2014-10-31 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 31 October 2014 at 23:59:54 UTC, dajones wrote: So shouldnt char[] implicity convert to string Nope, char[] casting to string is generally a bad thing that should be avoided because it can leave you with a mutable string, which isn't supposed to happen. In your case, why are you

Re: rndtonl

2014-11-04 Thread Adam D. Ruppe via Digitalmars-d-learn
I think rndtonl is a C library function that isn't always present in the system. It doesn't work on my computer either and I can't find any documentation about it. It is probably not meant to be called by end users.

Re: Access Violation Tracking

2014-11-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 11:31:01 UTC, bearophile wrote: This was discussed some times, and Walter is against this, but I think he is wrong, and eventually things will change. An access violation already thrown on Win32. Just catch a Throwable in main and write out exception.toString.

Re: How to turn this C++ into D?

2014-11-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 18:10:38 UTC, Ali Çehreli wrote: If so, then that push_back would be adding an incomplete object to the list. scope(success)? But the D translation worries me too because the destructor won't run at the same time as the C++ version, unless you make it a

Re: How to tell how an object/class is declared

2014-11-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 6 November 2014 at 23:43:19 UTC, Meta wrote: How can I tell at the points marked in the above code if the class or struct instance was declared as const, shared, etc.? Is this possible? You can't do that, but you can overload on const void doSomething() const { called on const

Re: D1: Error: function ... cannot have an in contract when overriden function

2014-11-07 Thread Adam D. Ruppe via Digitalmars-d-learn
If it is just that one error, you could always just comment out the in contract and recompile.

Re: ODBC Library?

2014-11-10 Thread Adam D. Ruppe via Digitalmars-d-learn
I kinda slapped one together but idk if it actually works. https://github.com/adamdruppe/arsd database.d and mssql.d from that repo. I haven't even tried to compile it for a while though, so it might not work at all. The way I made it was to write the extern(C) function declarations and

Re: Strictness of language styling

2014-11-10 Thread Adam D. Ruppe via Digitalmars-d-learn
Personally, I don't really care about naming conventions. I prefer the camelCase and it seems most D people do, but if you're translating another library, there's value it keeping it the same for ease of documentation lookups from the original etc.

Re: passing duck-typed objects and retaining full type information

2014-11-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 12 November 2014 at 01:50:07 UTC, Adam Taylor wrote: Adam Ruppe has an interesting example: What that does is defer the type work to runtime, so a lot of type information is lost there too. The big magic is that the wrapper object is a template, specialized for the compile

Re: Basically want to make a macro script

2014-11-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 13 November 2014 at 02:45:34 UTC, Israel wrote: Do you have plans for making win32 bindings for the sendkeys? I'm pretty sure it just calls this function: http://msdn.microsoft.com/en-us/library/ms646310%28v=vs.85%29.aspx with appropriate input prepared. As to listen to

Re: Callbacks in D as void functions

2014-11-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 13 November 2014 at 14:50:00 UTC, Wsdes wrote: I am trying to write a wrapper for a C API in D. In C I have the following definition of a callback type: typedef void (*Callback)(void*); I would translate this directly to D: extern(C) alias Callback = void function(void*);

Re: Basically want to make a macro script

2014-11-13 Thread Adam D. Ruppe via Digitalmars-d-learn
I wrote a program to get you started. It needs simpledisplay.d and color.d from my github https://github.com/adamdruppe/arsd Just download those two files and put them in your folder along with the following contents as hotkey.d and you should get started. I tested on Windows 7 to hotkey

Re: Basically want to make a macro script

2014-11-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 13 November 2014 at 07:01:08 UTC, Rikki Cattermole wrote: I did find this [0]. I don't know what state its in for compilating/running ext. But it might give you a good starting point. [0] https://github.com/pythoneer/XInputSimulator ooh there's some nice code for Linux in

  1   2   3   4   5   6   7   8   9   10   >