dirEntries throws exception on broken symlinks

2014-01-05 Thread dennis
I a using dirEntries to list recursively build a list of all files in all subdirectories but dirEntries is throwing an exception when it encounters a broken link. I want just report the exception, then ignore the broken link and then continue processing the rest of the dir's and files. Do I

Re: dirEntries throws exception on broken symlinks

2014-01-05 Thread dennis
On Sunday, 5 January 2014 at 21:33:56 UTC, FreeSlave wrote: You must not cast base class to derived class, when you don't know actual type (and even if you know exact type it's still bad practice to cast instance of more generic type to more specific one). Use multiple catch statements instead:

std.json tree navigation help

2014-01-26 Thread dennis
I am having trouble understanding how to navigate the tree returned by std.json. I am new to D programming, I have tried reading the std.json source code but I am still stumped. I want to iterate the tree of JSONValue(s) by the json objects key names and I need to be test the type of the valu

Re: std.json tree navigation help

2014-01-27 Thread dennis
On Monday, 27 January 2014 at 23:26:44 UTC, cal wrote: I usually end up doing something like this when dealing with std.json: http://dpaste.dzfl.pl/bcb14d6a; Cool, thank you. Your example really helps clear this up for me. Plus I liked the use of the popBackN() method call on the string, I

Re: associative arrays

2012-01-09 Thread dennis luehring
assert(key in aa); aa.remove(key); So, as far as I can tell, the current situation is more efficient, and it doesn't cost you any expressiveness. You can still have an exception thrown when remove fails if you use enforce before the call if you want an exception thrown when the element isn't ther

Re: associative arrays

2012-01-09 Thread dennis luehring
Am 09.01.2012 22:08, schrieb Manfred Nowak: dennis luehring wrote: why is there an exception/error neeeded if missing? Exceptions or errors are not _needed_. Their existence stems from the modell under which the user of the operation _has_ to think about the operation, especially whether it

Re: floating-WTF

2012-01-24 Thread dennis luehring
can you give us a complete out-of-the-box compileable example (with imports,main,etc.) with both examples the working/and nonworking does it work correct with dmd(32bit)? is this "calculate2" needed to reproduce the behavior? and what compiler did you test: dmd64, (dmd32?), ...? Am 24.01.2012

Re: floating-WTF

2012-01-24 Thread dennis luehring
double works correct under dmd64, but float not? what is the behavior of dmd32 in this szenario?

Re: floating-WTF - Compiler-BUG with 64bit

2012-01-24 Thread dennis luehring
nop I'm going to eat now. On 01/24/2012 05:01 PM, dennis luehring wrote: can you give us a complete out-of-the-box compileable example (with imports,main,etc.) with both examples the working/and nonworking does it work correct with dmd(32bit)? is this "calcu

Re: floating-WTF - Compiler-BUG with 64bit

2012-01-24 Thread dennis luehring
Am 24.01.2012 19:13, schrieb Caligo: How did you compile it? As in my original post, it matters how you compile it. In this case (I'm on a 64-bit GNU/Linux system), compiling with '-inline' doesn't trigger the bug. im on win7 (64bit) - but the windows dmd2.057 isn't able to produce x64 code

why have protection attributes on/in interfaces abstract classes/methods no effect ouside a module?

2012-02-03 Thread dennis luehring
why have protection attributes on/in interfaces and abstract classes/methods no effect outside a module? module types; private interface itest { private static void blub(); public void blub2(); private void blub3(); } private class test { protected abstract void blub4(); public abstr

Re: Raw socket TCP/IP

2012-03-07 Thread dennis luehring
Am 08.02.2012 19:35, schrieb Eyyub: BUMP, I really need help please ! Eyyub. what are you trying to archive? did you got an Ethernet-Frame+IP-Frame+(your replacement for tcp or udp) - or are your trying to change the tcp frame before sending? and if your using Windows: http://msdn.mi

Re: HelloWordl in Webserver

2012-03-18 Thread dennis luehring
Am 17.03.2012 21:08, schrieb Xan: I dont' want to battle among languages, its maybe only a library battle > but I see that in Golang there is a beatiful solution to display HelloWorld program in web server [rosettacode.org/wiki/Hello_world/Web_server#Go]. no its creates and simple webserver

Re: Problem about lambda expressions

2012-03-27 Thread dennis luehring
Am 27.03.2012 15:52, schrieb Tongzhou Li: Oh, I also tried: void seq_apply(Params..., Args...)(void delegate(Params) func, Args args) But I got a error: variadic template parameter must be last Does it mean that there can only be one variadic template parameter? How to fix it? Thanks

Re: parallel unzip in progress

2012-04-04 Thread dennis luehring
Am 04.04.2012 08:31, schrieb Jay Norwood: On Tuesday, 3 April 2012 at 05:27:08 UTC, Jay Norwood wrote: .. So, to answer my own questions ... I placed the code below in a taskpool parallel foreach loop, where each am is an archive member. It is expanded, and the expanded data is written

Re: DMD/Windows: Inspect generated ASM?

2012-04-08 Thread dennis luehring
ida 5.0 freeware http://www.hex-rays.com/products/ida/support/download_freeware.shtml Am 08.04.2012 14:42, schrieb Stefan: Hi all, Which is the most convenient way to have a look at the ASM code generated by Win-dmd? Unlike gdc, dmd it has no -S option, so I guess I will have to disassemble .o

Re: floats default to NaN... why?

2012-04-13 Thread dennis luehring
Am 14.04.2012 06:00, schrieb F i L: struct Foo { int x, y;// ready for use. float z, w; // messes things up. float r = 0; // almost always... } how often in your code is 0 or 0.0 the real starting point? i can't think of any situation except counters or

Re: floats default to NaN... why?

2012-04-14 Thread dennis luehring
Am 14.04.2012 07:48, schrieb F i L: On Saturday, 14 April 2012 at 05:19:38 UTC, dennis luehring wrote: Am 14.04.2012 06:00, schrieb F i L: struct Foo { int x, y;// ready for use. float z, w; // messes things up. float r = 0; // almost always

Re: void pointer syntax

2012-05-15 Thread dennis luehring
Am 14.05.2012 20:40, schrieb Stephen Jones: Ali Çehreli post got your answer - see the last example of the post news://news.digitalmars.com:119/jov3gn$2vtg$1...@digitalmars.com but first: try to understand how the base-class, interface stuff realy works - you will got the same problems in every

Re: void pointer syntax

2012-05-16 Thread dennis luehring
>Am 16.05.2012 13:12, schrieb Stephen Jones: just throw aways your sensless void pointer or whatever idea - create a base interface or better base-class - everything else is just damn wrong btw: all oop widget sets for c++, java or else are haveing a widget base class that works like people t

Re: Immutability and other attributes, please review

2012-06-14 Thread dennis luehring
Am 14.06.2012 15:26, schrieb Roman D. Boiko: But now, with everything immutable, I had to comment out several test cases. I cannot pass an immutable struct allocated on stack, into a method by reference, and then store a pointer to it, thats sounds very evil - with or without immutable how shou

Re: Immutability and other attributes, please review

2012-06-15 Thread dennis luehring
Am 15.06.2012 08:25, schrieb Jacob Carlborg: On 2012-06-14 17:32, Roman D. Boiko wrote: I agree, just looking how to accomplish my goals. I decided to get rid of casting, and will store everything on heap. I don't know how to put a variable of type float to the heap, and thought that it would b

Re: float[] → Vertex[] – decreases performance by 1000%

2012-07-26 Thread dennis luehring
Am 26.07.2012 21:18, schrieb David: Hm. Do you ever do pointer arithmetic on Vertex*? Is the size and offsets are correct (like in Vertex vs float)? No, yes. I really have no idea why this happens, I saved the contents of my buffers and compared them with the buffers of the `float[]` version (

Re: static code generation

2012-12-12 Thread dennis luehring
Am 13.12.2012 04:32, schrieb js.mdnq: I think the issue I have with all this is that when you put code inside a string you lose a lot of compile time features AFAICT. your right - but...try to come up with an similar ("easy" to implement) powerfull solution that is not based on strings and you

Re: Inner function overload bug?

2013-01-09 Thread dennis luehring
Am 08.01.2013 22:43, schrieb Era Scarecrow: On Tuesday, 8 January 2013 at 21:12:34 UTC, Philippe Sigaud wrote: It's conform to the spec http://dlang.org/function.html Last line of the 'nested functions' subsection: "Nested functions cannot be overloaded." Nested functions cannot be overloaded

Re: Inner function overload bug?

2013-01-09 Thread dennis luehring
Am 09.01.2013 14:21, schrieb Philippe Sigaud: On Wed, Jan 9, 2013 at 12:52 PM, Era Scarecrow wrote: That's weird. Why does that work? Directly pasting the mixin content in main() does not compile, right? I can only assume if it does work, that the mixin template has it's own scope that enab

Re: Trouble with DLL address

2013-01-14 Thread dennis luehring
Just ignore my post - too early in the morning :( Am 14.01.2013 10:19, schrieb dennis luehring: http://dlang.org/type.html int => signed 32 bits but don't you need long in D Am 14.01.2013 10:13, schrieb dnewbie: I have a DLL which exports a function GetFunction. GetFunction r

Re: Trouble with DLL address

2013-01-14 Thread dennis luehring
http://dlang.org/type.html int => signed 32 bits but don't you need long in D Am 14.01.2013 10:13, schrieb dnewbie: I have a DLL which exports a function GetFunction. GetFunction returns a pointer to RealFunction. Now I want to run RealFunction from my D program, but for some reason I get the

try to compile githubs dmd-master zip with vstudio 2010

2013-01-27 Thread dennis luehring
i've grabbed the dmd-master.zip from github an opended the dmd_msc_vs10.sln but i get 3 errors C:\Test\dmd-master\src\mars.c wants missing include verstr.h C:\Test\dmd-master\src\c1xx missing ph.h C:\Test\dmd-master\src\c1xx missing util.c what else is needed to build from source this way?

Re: try to compile githubs dmd-master zip with vstudio 2010

2013-01-27 Thread dennis luehring
and if i want to use the solution file? Am 27.01.2013 14:45, schrieb Namespace: I had the same problem, few days ago. I wrote this short make script [1] which works for me. My solution is that you must clean before, call the vs buildme and then build again with the normal make file. Sounds weird

Re: try to compile githubs dmd-master zip with vstudio 2010

2013-01-29 Thread dennis luehring
Am 27.01.2013 15:08, schrieb Namespace: You mean the Visual Studio solution? I tried it also, but for me only the solution above works fine. I asked for that problem here: http://forum.dlang.org/thread/rzvaprvvgdtwrnoto...@forum.dlang.org?page=2#post-ehulzblzddasvyxncvdb:40forum.dlang.org can

is there a way to define a pure base class that forces pureness of derived classes?

2013-02-02 Thread dennis luehring
i've got something like an streaming/converter system and parts of the specialised converters are stateless other statefull is there any way to force pureness/stateless-ness through the base class or an interface in D?

Re: static class

2013-02-18 Thread dennis luehring
Am 17.02.2013 23:25, schrieb Jonathan M Davis: On Sunday, February 17, 2013 23:00:19 Michael wrote: > That's not the meaning of static in that context. As I understand a static class can't be instantiated. I have no idea how you came to that conclusion. That's not what it means for a class to

Re: Linker errors and how to catch them

2013-02-18 Thread dennis luehring
Am 18.02.2013 18:37, schrieb Lubos Pintes: Hi, I already did this. I am playing with that library. I converted it so that it uses win32 windows api bindings and fixed a bunch of compile errors. I also converted enum names "So_THEY_ARE_NOT_SO_UGLY". :-). Everything worked fine with 2.060. you co

Re: Why is this code returning the wrong type?

2013-05-23 Thread dennis luehring
Am 23.05.2013 21:45, schrieb Gary Willoughby: Hmmm... Following your example i'm still having problems compiling this simple snippet: import std.stdio; class Example { private FILE _file; public this(string file) { this._file = File(file, "r"); }

Re: Latest GDB version problems

2013-06-02 Thread dennis luehring
the post ist more than 3 years old Am 02.06.2013 07:04, schrieb sha0coder: (gdb) p s $1 = 578159222890430469 No luck :( try this: (gdb) x/dwx &mystirng 0xb4f4: 0x003c<- size of string (gdb) 0xb4f8: 0xb7ca2540<- ptr to the string (gdb) x/s 0xb7ca2540 0xb7c

Re: Should it be a compile time error?

2013-06-19 Thread dennis luehring
Am 19.06.2013 13:40, schrieb Iain Buclaw: On Wednesday, 19 June 2013 at 11:33:43 UTC, deed wrote: The following compiles and crashes with DMD 2.063. Should this be a compile time error? class A { int _var; /* SNIP */ int var() @property { return var; } Isn't the

Re: Should it be a compile time error?

2013-06-19 Thread dennis luehring
that isn't the problem - D allows assignment to an read property - and there is no write property around, so it should be an compiletime error i should compile only if the missing write property is available - or? @property int var(int value) { return _var = value; } sorry i've totaly lost se

Re: Source code output

2013-07-17 Thread dennis luehring
Am 17.07.2013 09:33, schrieb Jacob Carlborg: On 2013-07-17 05:27, JS wrote: With heavy ctfe code generation usage is it possible to have the d compiler output the source code after all mixin templates have been "used"? This way it is easier to visually check for errors in the generated code. I

Re: Auto keyword with const variable

2013-07-24 Thread dennis luehring
Am 24.07.2013 11:39, schrieb bearophile: Alex H: void test(const int n) { auto j = n; j++; } Gives this error: cannot modify const expression j Is this considered a feature or a bug? I would assume most people wouldn't want new variables inheriting const. It's a bit annoyin

Re: Socket.select interrupted system call because of GC

2013-08-03 Thread dennis luehring
Am 03.08.2013 08:38, schrieb Marek Janukowicz: void main () { writefln( "sa: %d", SA_RESTART ); (new Thread (&serverfunc)).start(); (new Thread (&clientfunc)).start(); } i have no idea to your main problem but firing threads without any join on the threads in your main program seems v

Re: Socket.select interrupted system call because of GC

2013-08-03 Thread dennis luehring
Am 03.08.2013 13:35, schrieb Marek Janukowicz: dennis luehring wrote: Am 03.08.2013 08:38, schrieb Marek Janukowicz: void main () { writefln( "sa: %d", SA_RESTART ); (new Thread (&serverfunc)).start(); (new Thread (&clientfunc)).start(); } i have no idea to you

Re: Which option is faster...

2013-08-05 Thread dennis luehring
did you benchmarked your current szenario - how do you know that this is the slow part - or are you working on an only-extension-compare-tool? btw: they are both equal and slow - and full of partly code-duplication std.string.tolower(fext[0]) multiple times, i hope your list isn't going much lo

Re: Which option is faster...

2013-08-05 Thread dennis luehring
s "do it with assembler that would it make million times faster" blabla) question: is this the slow part in your project? do you know it for sure or just an emotion - HOW do you benchmark? Am 05.08.2013 16:31, schrieb jicman: On Monday, 5 August 2013 at 14:27:43 UTC, dennis luehri

Re: Which option is faster...

2013-08-05 Thread dennis luehring
Am 05.08.2013 17:18, schrieb jicman: > It is a tool that was a script, but I have turned it into do, which now has taken two hours from the last jscript script. I have not benchmarked it, yet. I may. But I see that a great idea has been provided, which I will use. Thanks for the help. > hav

Re: Which option is faster...

2013-08-05 Thread dennis luehring
Am 05.08.2013 19:04, schrieb jicman: so its totaly unclear if the presented code is your 2h monster, what was the runtime of your jscript? The files are in a network drive, so, that has some slowness already involved because of that. The jscript use to take over 8 hours. The new D program has

Re: Getting number of messages in MessageBox

2013-08-06 Thread dennis luehring
Am 06.08.2013 09:30, schrieb Marek Janukowicz: Gabi wrote: Why not go for the trivial solution - just increase/decrease a counter for each push/pop message? Yeah, that's most likely what I'll end up with, but it's a pity such information exists and I only can't access it because someone decid

Re: Which option is faster...

2013-08-06 Thread dennis luehring
Am 07.08.2013 06:30, schrieb jicman: Again, what are you trying to achieve? Your statement is not necessarily true, for a myriad of reasons, but it entirely depends on what you want to do. I would reiterate Dennis Luehring's reply, why are you not benching? It seems like you are guessi

Re: Disassembly Tool

2013-11-14 Thread dennis luehring
Am 14.11.2013 10:48, schrieb Namespace: Since the disassembly on Dpaste doesn't work for me anymore, I'm looking for an alternative. Is there one? And I don't want obj2asm, I'm not willing to pay 15$. maybe: distorm: http://www.ragestorm.net/distorm/ ida freeware: https://www.hex-rays.com/pr

Re: delegates with C linkage

2010-06-05 Thread dennis luehring
Am 05.06.2010 13:33, schrieb Zarathustra: Secondly, I'm not sure if you can pass delegates to a C function. C code wouldn't understand delegates. They are not the same as function pointers. I suggest you use function pointers instead, paying attention to linkage. Of course It is possible, b

Re: delegates with C linkage

2010-06-05 Thread dennis luehring
Am 05.06.2010 15:42, schrieb Zarathustra: only with static methods - a real delegate needs the this-pointer in a register (not on the stack), thats the main difference between function ptr and delegates, thats why you can't use a (non static) method on for example the win-api callbacks, becau

Re: delegates with C linkage

2010-06-05 Thread dennis luehring
Am 05.06.2010 16:03, schrieb dennis luehring: Am 05.06.2010 15:42, schrieb Zarathustra: only with static methods - a real delegate needs the this-pointer in a register (not on the stack), thats the main difference between function ptr and delegates, thats why you can't use a (non s

Re: delegates with C linkage

2010-06-06 Thread dennis luehring
Am 06.06.2010 11:33, schrieb Simen kjaeraas: Also, pointers to delegates can be passed to C-linkage functions. A delegate is nothing but a struct, and as such there is no reason for it not to be passable to a C-linkage function. my fault - yes its possible to use delegates in non D but delegat-

Re: delegates with C linkage

2010-06-06 Thread dennis luehring
Am 06.06.2010 17:30, schrieb Zarathustra: are delegats part of the ABI, i can't find a delegat calling scheme in the ABI-Description - should this be in EAX, as last/first part on stack, ECX? The delegates are called by exactly same way as any other member function. Put ptr = 'this'(context

Re: Why assert is in the language?

2010-06-22 Thread dennis luehring
Am 22.06.2010 23:07, schrieb Tomek Sowiñski: Yes, why? It could be implemented in object.d in a similar fashion as std.contracts.enforce. Does it do anything special that a library function couldn't? Tomek what about static assert?

Re: associative array of associative arrays.

2010-08-12 Thread dennis luehring
Am 13.08.2010 01:17, schrieb dcoder: string[string][string] leaders or try using alias to "see" the light alias string[string] city_info; city_info[string] leaders; Hello. How do you declare and initialize a map that looks like the following: Name => [ Personal Info] Where personal info

Re: about float & double

2011-01-19 Thread dennis luehring
Is there somewhere a (clear) doc about float/double internals? Some more particuliar questions: What is the internal bit layout? (mantissa, sign, exponent) Can I assume the "integral range" is [-2^(m-1) .. 2^�m-1)-1], where m is the number of mantissa bits? What are the values used to represe

Re: Nested function declarations

2011-01-29 Thread dennis luehring
They're useful for testing: unittest { int foo(); static assert (is(ReturnType!foo == int)); } and else? is it worth?

Re: Setting thread priority

2011-02-07 Thread dennis luehring
Am 06.02.2011 02:58, schrieb Peter Alexander: How do you set the priority of a thread, or otherwise control how much CPU time it gets? depends on operating system - on windows: set the priority to high does not help if your system isn't under pressure ...

Re: How to search news group?

2011-05-12 Thread dennis luehring
Am 12.05.2011 15:24, schrieb Matthew Ong: Hi D Forum Admin, I am using the webbase interface for the forum. How to do forum text search instead of browsing over them one by one? Matthew Ong use thunderbird as newsclient

Re: Any example of using these Special Tokens?

2011-05-25 Thread dennis luehring
Am 25.05.2011 12:42, schrieb Matthew Ong: On 5/25/2011 5:45 PM, bearophile wrote: Matthew Ong: I am not able make use of these 3 special tokens to print something. writefln("gshared: %s",__gshared); writefln("thread: %s",__thread); writefln("traits: %s",__traits); They are keywords, s

Re: Any example of using these Special Tokens?

2011-05-25 Thread dennis luehring
Am 25.05.2011 10:29, schrieb Matthew Ong: Hi, I am not able make use of these 3 special tokens to print something. writefln("gshared: %s",__gshared); writefln("thread: %s",__thread); writefln("traits: %s",__traits); rc\Sample.d(128):

Re: d2 file input performance

2011-09-02 Thread dennis luehring
Am 26.08.2011 19:43, schrieb Christian Köstlin: Hi guys, i started the thread: http://stackoverflow.com/questions/7202710/fastest-way-of-reading-bytes-in-d2 on stackoverflow, because i ran into kind of a problem. i wanted to read data from a file (or even better from a stream, but lets stay wi

Re: TLF = thread local functions

2014-01-23 Thread dennis luehring
Am 23.01.2014 15:44, schrieb Frustrated: So, TLS solves the data issue with threading. I just thought, with out much thinking, what about having thread local functions? Doesn't make sense? Let me explain. Functions generally are not thread safe because of reentry, right? The same data is used by

Re: Interface to Microsoft Access database (Jet)

2014-03-11 Thread dennis luehring
Am 11.03.2014 08:37, schrieb Orfeo: I should extract and process data from Microsoft Access database, and mdbtools is not enough. Is there a library that I can use to query Access? Thanks "mdbtools is not enough" what is not enough? what "version" of mdbtools do you use https://github.com/

Re: Interface to Microsoft Access database (Jet)

2014-03-11 Thread dennis luehring
Am 11.03.2014 09:06, schrieb Orfeo: Thank you for github link, I had tried only with mdbtools on http://mdbtools.sourceforge.net/... So, it seems that I can connect using libmdb or odbc ... so everything is fine? or "I can not" have you any suggestions? answer the question what do you n

Re: Factory class

2009-03-19 Thread dennis luehring
void main() { auto pizza = PizzaFactory.factory(); pizza.doSome(); // OK pizza.doSomeA(); // error: IPizza.doSomeA() not found } you interface has only doSome() and that is what factory returns and for all others: factories and cast don't belong together you interface should fit yo

File.byLine for either Windows / Unix newlines

2017-12-11 Thread Dennis via Digitalmars-d-learn
I'm on Windows and I recently got confused by how Phobos functions handle newlines. ``` void main() { import std.stdio; import std.path : buildPath, tempDir; auto path = buildPath(tempDir(), "test.txt"); auto file = new File(path, "w"); file.write("hello there!\n"); //act

Re: File.byLine for either Windows / Unix newlines

2017-12-11 Thread Dennis via Digitalmars-d-learn
Thanks for your reply, that clears it up. On Monday, 11 December 2017 at 21:13:11 UTC, Steven Schveighoffer wrote: 3. Stop using Windows ;) Haha, if only the rest of the userbase would follow.

bitmanip : read does not accept my array slice

2017-12-26 Thread Dennis via Digitalmars-d-learn
I was trying to translate this kind of C code to D: void calc(unsigned char *buf) { (...) res = read_u32_be(&buf[i]); } So I tried this: import std.bitmanip : read, Endian; void calc(ubyte[] buf) { (...) res = read!(uint, Endian.bigEndian)(buf[i..$]); } But then I get this error: templ

Re: bitmanip : read does not accept my array slice

2017-12-26 Thread Dennis via Digitalmars-d-learn
Ah, so it's about lvalues an rvalues, not the type of the range. Makes sense now. On Tuesday, 26 December 2017 at 22:33:54 UTC, WebFreak001 wrote: BigEndian is default btw, you don't need to specify that but you can if you want. Dealing with Endianness bugs has been such a pain, I like to be

Elegant way to use dynamic bindings

2018-02-09 Thread Dennis via Digitalmars-d-learn
I want to bind to a .dll on Windows, so I looked at how Derelict packages are doing it and found it does it like this: ``` extern(C) { alias da_CoreGetAPIVersions = m64p_error function(int*,int*,int*,int*); ... } __gshared { da_CoreGetAPIVersions CoreGetAPIVersions; ... } protected o

Re: Elegant way to use dynamic bindings

2018-02-09 Thread Dennis via Digitalmars-d-learn
I read the Derelict documentation a while ago, I didn't grasp all of it. Reading it again, I can now make sense of it though. :) On Friday, 9 February 2018 at 12:53:44 UTC, Mike Parker wrote: Did you link with the library you created with implib? That linker error suggests you didn't. I added

Re: Elegant way to use dynamic bindings

2018-02-09 Thread Dennis via Digitalmars-d-learn
On Friday, 9 February 2018 at 14:51:30 UTC, Mike Parker wrote: Where was the lib file located? Was it in the root project directory? How are you compiling your project? What does your directory tree look like? (...) That depends. Is that the directory where your executable is written? Are you

Re: Elegant way to use dynamic bindings

2018-02-09 Thread Dennis via Digitalmars-d-learn
On Friday, 9 February 2018 at 18:14:06 UTC, Mike Wey wrote: You may need to pass `/s` to implib so it will add the underscore to the symbol in the import library. If it's actually needed depends on what the dll uses. That did it, now both dynamic loading and dynamic linking work. :) Thanks bo

Re: Link to https://run.dlang.io/ ??

2018-02-20 Thread Dennis via Digitalmars-d-learn
I recently tried to go to that site, and I tried `run.dlang.com` which is the wrong URL. So I was looking through the D homepage for the right link but couldn't find it. Even a Google search for "online d compiler" or "run dlang online" didn't turn up anything directly, I had to go through the

importing std.array: empty in a struct messes things up

2018-03-04 Thread Dennis via Digitalmars-d-learn
I was making a stack interface for an array: ``` struct Stack(T) { import std.array: empty; T[] stack; alias stack this; } void main() { Stack!int stack; bool x = stack.empty; } ``` My expectation is that you can now call `empty` on a stack instance since I imported it in the

Re: Elegant way to use dynamic bindings

2018-03-08 Thread Dennis via Digitalmars-d-learn
On Friday, 9 February 2018 at 20:19:33 UTC, Dennis wrote: I'd still like to find a nice way to generate the boilerplate code for dynamic loading, if I come up with something I'll post it here. So I ended up using an import library for a while, but I then wanted to get the handle

Re: Logging Function Parameters

2018-03-18 Thread Dennis via Digitalmars-d-learn
On Sunday, 18 March 2018 at 22:57:15 UTC, aliak wrote: // But you get a: // Error: Using the result of a comma expression is not allowed // writeln(mixin(arguments!f)); You can't mix part of a function call in: "Mixed in text must form complete declarations, statements, or expres

Slow start up time of runtime

2018-03-20 Thread Dennis via Digitalmars-d-learn
Simply running a "hello world.exe" takes, on my pc: 1.12s When compiled with dmd 0.62s When compiled with ldc 0.05s When compiled with dmc (C program) or dmd/ldc as a -betterC program I suppose initializing the runtime takes a lot of time. When making a simple command line utility, half a sec

Re: Slow start up time of runtime

2018-03-20 Thread Dennis via Digitalmars-d-learn
On Tuesday, 20 March 2018 at 09:51:09 UTC, bauss wrote: Besides if it was and it took 1 second to startup, then it wouldn't matter in practice with an actual application. This is not concerning for large applications indeed. But say, I want to implement my own `dir` (= `ls` on Unix) in D. Woul

Re: Slow start up time of runtime

2018-03-20 Thread Dennis via Digitalmars-d-learn
On Tuesday, 20 March 2018 at 10:20:55 UTC, Dennis wrote: On Tuesday, 20 March 2018 at 09:51:09 UTC, bauss wrote: Besides if it was and it took 1 second to startup, then it wouldn't matter in practice with an actual application. This is not concerning for large applications indeed. But sa

Re: Slow start up time of runtime (correction: Windows real-time protection)

2018-03-20 Thread Dennis via Digitalmars-d-learn
On Tuesday, 20 March 2018 at 12:18:16 UTC, Adam D. Ruppe wrote: On Tuesday, 20 March 2018 at 09:44:41 UTC, Dennis wrote: I suspect you are seeing the Windows antivirus hitting you. D runtime starts up in a tiny fraction of a second, you shouldn't be noticing it. You're tot

Re: Slow start up time of runtime (correction: Windows real-time protection)

2018-03-21 Thread Dennis via Digitalmars-d-learn
On Wednesday, 21 March 2018 at 13:26:48 UTC, HeiHon wrote: I added exclusions for the folder, where I installed dmd and ldc and I added an exclusion for the folder, where I compile my D programs. Now startup of dmd and freshly compiled programs is fast again. I've done this too now, thanks fo

Re: how to correctly populate an array of dynamic closures?

2018-03-29 Thread Dennis via Digitalmars-d-learn
On Thursday, 29 March 2018 at 15:16:07 UTC, Ivan Kazmenko wrote: So, why do delegates of guns[] and huns[] all return 1, and how to correctly reproduce the behavior of funs[] while populating it in a loop? A delegate is a function with a pointer to the stack frame where it was created. It doe

Re: @property for simple methods?

2018-04-02 Thread Dennis via Digitalmars-d-learn
On Monday, 2 April 2018 at 13:57:14 UTC, Vladimirs Nordholm wrote: Is there any reason for me to add the @property tags for the method? A list of things the @property tag does can be found here: https://dlang.org/spec/function.html#property-functions This behavior is particularly useful for ge

Re: @property for simple methods?

2018-04-02 Thread Dennis via Digitalmars-d-learn
On Monday, 2 April 2018 at 14:51:57 UTC, Vladimirs Nordholm wrote: Do you think I should I omit the @property tag, if the only wanted behaviour is to set a value (`foo.bar = "baz";`) ? You're probably fine either way, it's mostly for making your intention clear. Jonathan M Davis made a great e

Re: "%s"-format template function arguments

2018-04-15 Thread Dennis via Digitalmars-d-learn
On Sunday, 15 April 2018 at 12:04:19 UTC, vladdeSV wrote: How would I go on about to print all the arguments as I expected it, using "%s"? You can expand the template arguments into an array by putting it into square brackets: [args]. You can format an array with the default notation using %s

Splitting up large dirty file

2018-05-15 Thread Dennis via Digitalmars-d-learn
I have a file with two problems: - It's too big to fit in memory (apparently, I thought 1.5 Gb would fit but I get an out of memory error when using std.file.read) - It is dirty (contains invalid Unicode characters, null bytes in the middle of lines) I want to write a program that splits it u

Re: Splitting up large dirty file

2018-05-16 Thread Dennis via Digitalmars-d-learn
On Wednesday, 16 May 2018 at 02:47:50 UTC, Jon Degenhardt wrote: Can you show the program you are using that throws when using byLine? Here's a version that only outputs the first chunk: ``` import std.stdio; import std.range; import std.algorithm; import std.file; import std.exception; void m

Re: Splitting up large dirty file

2018-05-16 Thread Dennis via Digitalmars-d-learn
On Wednesday, 16 May 2018 at 08:20:06 UTC, drug wrote: What is the purpose of `.drop(4)`? I'm pretty sure this is the reason of the exception. The file in question is a .json database dump with an array "rows" of 10 million 8-line objects. The newlines in the string fields are escaped, but th

Re: Splitting up large dirty file

2018-05-16 Thread Dennis via Digitalmars-d-learn
On Wednesday, 16 May 2018 at 08:20:06 UTC, drug wrote: What is the purpose of `.drop(4)`? I'm pretty sure this is the reason of the exception. The file in question is a .json database dump with an array "rows" of 10 million 8-line objects. The newlines in the string fields are escaped, but th

Re: Splitting up large dirty file

2018-05-17 Thread Dennis via Digitalmars-d-learn
On Wednesday, 16 May 2018 at 15:47:29 UTC, Jon Degenhardt wrote: If you write it in the style of my earlier example and use counters and if-tests it will work. byLine by itself won't try to interpret the characters (won't auto-decode them), so it won't trigger an exception if there are invalid

Re: Splitting up large dirty file

2018-05-17 Thread Dennis via Digitalmars-d-learn
On Wednesday, 16 May 2018 at 10:30:34 UTC, Jonathan M Davis wrote: For various reasons, that doesn't always hold true like it should, but pretty much all of Phobos is written with that assumption and will generally throw an exception if it isn't. It's unfortunate that Phobos tells you 'there's

Re: UFCS syntax I never saw before.

2018-05-21 Thread Dennis via Digitalmars-d-learn
On Monday, 21 May 2018 at 11:38:12 UTC, SrMordred wrote: what?? Here's another weird example: ``` void funWithUfcsAndPropertySyntax() { import std.typecons : tuple; "%s %s".writefln = ("foo".tuple = "bar").expand; } ``` source: https://github.com/Hackerpilot/Idiotmatic-D/blob/

Re: Splitting up large dirty file

2018-05-21 Thread Dennis via Digitalmars-d-learn
On Thursday, 17 May 2018 at 21:10:35 UTC, Dennis wrote: It's unfortunate that Phobos tells you 'there's problems with the encoding' without providing any means to fix it or even diagnose it. I have to take that back since I found out about std.encoding which has func

Re: Splitting up large dirty file

2018-05-21 Thread Dennis via Digitalmars-d-learn
On Monday, 21 May 2018 at 17:42:19 UTC, Jonathan M Davis wrote: On Monday, May 21, 2018 15:00:09 Dennis via Digitalmars-d-learn wrote: drop is range-based, so if you give it a string, it's going to decode because of the whole auto-decoding mess with std.range.primitives.front and pop

Re: How are switches optimized

2018-06-02 Thread Dennis via Digitalmars-d-learn
On Friday, 1 June 2018 at 21:18:25 UTC, IntegratedDimensions wrote: If one has a switch of N case then the last cost surely does not cost N times the cost of the first, approximately? It depends on the compiler and optimization level. In general, no optimization or just a handful of cases mean

Re: foreach DFS/BFS for tree data-structure?

2018-06-14 Thread Dennis via Digitalmars-d-learn
On Thursday, 14 June 2018 at 11:31:50 UTC, Robert M. Münch wrote: Is this possible? I read about Inputranges, took a look at the RBTree code etc. but don't relly know/understand where to start. You can also use opApply to iterate over a tree using foreach, see: https://tour.dlang.org/tour/en/

Re: Prime number

2018-08-02 Thread Dennis via Digitalmars-d-learn
On Thursday, 2 August 2018 at 08:30:05 UTC, Greatsam4sure wrote: I know D is very powerful from my little experience. What is the idiomatic way to get prime numbers say from 1-30 without using loops(outer and inner loop). Can map, filter, fold etc in algorithm be use. Pls show some code with c

  1   2   3   4   5   6   7   >