Re: mov reg,0 vs xor reg,reg in core.atomic ?

2016-04-10 Thread Ali Çehreli via Digitalmars-d-learn
On 04/10/2016 04:00 AM, darat wrote: Is there a particular reason explaining why mov reg,0 is used and not xor reg,reg ? (or even and reg, 0) for example here: https://github.com/D-Programming-Language/druntime/blob/master/src/core/atomic.d#L1009 It seems that in Go too mov is used:

Re: Casting a class variable to void*

2016-04-10 Thread ag0aep6g via Digitalmars-d-learn
On 11.04.2016 00:06, Manuel Maier wrote: So, is this a bug, or is it intended behavior? In case of the latter, I'd gladly add it to the documentation. Looks like a bug to me. And it's already been filed: https://issues.dlang.org/show_bug.cgi?id=13392

Re: execute bash?

2016-04-10 Thread Puming via Digitalmars-d-learn
On Sunday, 10 April 2016 at 10:43:48 UTC, wobbles wrote: This would be cool. I'll have a think about how to go about it! Looking forward to your updates! :P

Re: version pairs?

2016-04-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, April 10, 2016 13:58:17 Jay Norwood via Digitalmars-d-learn wrote: > Seems like there should be an extra level to the version > statement, something like version(arch,x86). > > I must be missing something about the intended use of the version > statement. In most cases that I've seen,

Re: Why is Linux the only OS in version identifier list that has a lowercase name?

2016-04-10 Thread Zekereth via Digitalmars-d-learn
On Monday, 11 April 2016 at 01:15:27 UTC, Ali Çehreli wrote: As a workaround, you can set version to Linux yourself: version (linux) { version = Linux; } void main() { version (Linux) { import std.stdio; writeln("Linux worked!"); } } That's interesting that will

Re: Why is Linux the only OS in version identifier list that has a lowercase name?

2016-04-10 Thread Zekereth via Digitalmars-d-learn
On Monday, 11 April 2016 at 00:51:19 UTC, Mike Parker wrote: It's an artifact of history. When this was first introduced, Walter's intent was to match the casing used in gcc preprocessor definitions. Since that time, we've standardized on capitalization for everything, but 'linux' lives on. I

Re: Why is Linux the only OS in version identifier list that has a lowercase name?

2016-04-10 Thread Ali Çehreli via Digitalmars-d-learn
On 04/10/2016 03:03 PM, Zekereth wrote: So I was just testing some code and couldn't figure out why it wasn't working. My version block looked like this: version(Linux) { ... } Looking at the list(unless I'm missing something) Linux is the only OS that is lowercase. I'm guessing most people

Re: execute bash?

2016-04-10 Thread Puming via Digitalmars-d-learn
On Sunday, 10 April 2016 at 02:59:41 UTC, Adam D. Ruppe wrote: On Sunday, 10 April 2016 at 00:47:28 UTC, Puming wrote: 3. when hiting 'vim a.file' on the command, things go messy. Have you got these interactive commands work in dexpect? It is surely capturing exactly what vim sends to a

Re: Internal compiler erorr

2016-04-10 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 10 April 2016 at 17:19:14 UTC, Eric wrote: I am getting this error when I compile: Error: Internal Compiler Error: unsupported type const(string) No line number is given. Does anyone know what causes this? compiler version = v2.071.0 -Eric An ICE should always be considered a

Re: Why is Linux the only OS in version identifier list that has a lowercase name?

2016-04-10 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 10 April 2016 at 22:03:54 UTC, Zekereth wrote: So I was just testing some code and couldn't figure out why it wasn't working. My version block looked like this: version(Linux) { ... } Looking at the list(unless I'm missing something) Linux is the only OS that is lowercase. I'm

Re: version pairs?

2016-04-10 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 10 April 2016 at 13:58:17 UTC, Jay Norwood wrote: Seems like there should be an extra level to the version statement, something like version(arch,x86). I must be missing something about the intended use of the version statement. What's wrong with version(X86)?

Re: Dub and derelict-allegro5 "Could not find a valid dependency tree configuration"

2016-04-10 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 10 April 2016 at 12:14:54 UTC, Pedro Lopes wrote: Hello, Every time I try to run a project with derelict-allegro5 package as a dependency, dub says: "Could not find a valid dependency tree configuration" I already cleaned the dub cache, that does not solve it, allegro package is

Re: Dub and derelict-allegro5 "Could not find a valid dependency tree configuration"

2016-04-10 Thread Mike Parker via Digitalmars-d-learn
On Monday, 11 April 2016 at 00:36:28 UTC, Mike Parker wrote: You say it happens when you try to "run" a project, but the error message sounds like it's happening before building even begins, correct? What platform are you on? What does your dub configuration look like? What does 'dub build

Re: Lazy evaluation of function pointers.

2016-04-10 Thread Ryan Frame via Digitalmars-d-learn
On Sunday, 10 April 2016 at 19:02:06 UTC, Alex Parrill wrote: A parameter declared as `lazy T` has the type `T delegate()`, which, when called, evaluates the expression that was passed into the function. So effectively, this: void foo(lazy int x) { auto i = x(); } foo(a+b); Is the same as

Casting a class variable to void*

2016-04-10 Thread Manuel Maier via Digitalmars-d-learn
I'm not sure whether I've found a bug or if I found some very strange but intended behavior. If it is indeed intended behavior, I'd like to know the rationale behind it because this one surprised me a lot when I found it out after 16+ hours of debugging... Have a look at this code snippet:

Why is Linux the only OS in version identifier list that has a lowercase name?

2016-04-10 Thread Zekereth via Digitalmars-d-learn
So I was just testing some code and couldn't figure out why it wasn't working. My version block looked like this: version(Linux) { ... } Looking at the list(unless I'm missing something) Linux is the only OS that is lowercase. I'm guessing most people use Posix instead and never encounter

Re: Cancelling a stdin.read?

2016-04-10 Thread Lass Safin via Digitalmars-d-learn
On Sunday, 10 April 2016 at 18:00:31 UTC, hilop wrote: On Sunday, 10 April 2016 at 08:29:22 UTC, Lass Safin wrote: I have a multi-threaded program, one thread drawing to a window and handling it, the other handling stdin. [...] The external program that writes to the input has to close it

Re: What is best way to get see function from separate file

2016-04-10 Thread Jonathan Villa via Digitalmars-d-learn
On Sunday, 10 April 2016 at 18:57:45 UTC, Suliman wrote: I like it. Am i right understand that it prevent creation unneeded of new instance of logger? No, you need to pass a valid instance in foo(...), It should have been created before the call to foo(...). I prefer the second way

Re: Putting things in an enum's scope

2016-04-10 Thread Mint via Digitalmars-d-learn
On Wednesday, 6 April 2016 at 13:59:42 UTC, pineapple wrote: Is there any way in D to define static methods or members within an enum's scope, as one might do in Java? It can sometimes help with code organization. For example, this is something that coming from Java I'd have expected to be

Re: Lazy evaluation of function pointers.

2016-04-10 Thread Alex Parrill via Digitalmars-d-learn
On Sunday, 10 April 2016 at 18:08:58 UTC, Ryan Frame wrote: Greetings. The following code works: void main() { passfunc(); } void passfunc(void function(string) f) { f("Hello"); } void func(string str) { import std.stdio : writeln; writeln(str); } Now if I change passfunc's

Re: What is best way to get see function from separate file

2016-04-10 Thread Suliman via Digitalmars-d-learn
You could pass an argument of type FileLogger (probably better a pointer?) foo ( FileLogger log ) { } I like it. Am i right understand that it prevent creation unneeded of new instance of logger? And what problems I can get if I will create new instance of logger in every stand alone

Extensible struct type via variadic template arguments

2016-04-10 Thread Joseph Rushton Wakeling via Digitalmars-d-learn
Hello all, I've been playing around recently with some new ideas for a reworking of my Dgraph library: https://github.com/WebDrake/Dgraph ... and particularly, considering how to use D's metaprogramming techniques to best allow the fundamental graph data structures to be extended

Re: What is best way to get see function from separate file

2016-04-10 Thread Jonathan Villa via Digitalmars-d-learn
On Sunday, 10 April 2016 at 18:26:57 UTC, Suliman wrote: Sorry for wrong posting! I have got logger instance in App.d void main() { ... FileLogger fLogger = new FileLogger("ErrorLog.txt"); foo(); } utils.d: foo() { // I need logging here } Also I have file utils.d that include stand-alone

Re: What is best way to get see function from separate file

2016-04-10 Thread Jonathan Villa via Digitalmars-d-learn
On Sunday, 10 April 2016 at 18:36:19 UTC, Jonathan Villa wrote: On Sunday, 10 April 2016 at 18:26:57 UTC, Suliman wrote: Other whay is to leave FileLogger instance in a separated module: logger.d public static FileLogger fLogger; App.d import logger; //the module void main() { //

Re: What is best way to get see function from separate file

2016-04-10 Thread Suliman via Digitalmars-d-learn
Sorry for wrong posting! I have got logger instance in App.d void main() { ... FileLogger fLogger = new FileLogger("ErrorLog.txt"); foo(); } utils.d: foo() { // I need logging here } Also I have file utils.d that include stand-alone functions that is not in classes. In one of them I need

What is best way to get see function from separate file

2016-04-10 Thread Suliman via Digitalmars-d-learn
I have got logger instance in App.d void main() { FileLogger fLogger = new FileLogger("ErrorLog.txt");

Lazy evaluation of function pointers.

2016-04-10 Thread Ryan Frame via Digitalmars-d-learn
Greetings. The following code works: void main() { passfunc(); } void passfunc(void function(string) f) { f("Hello"); } void func(string str) { import std.stdio : writeln; writeln(str); } Now if I change passfunc's signature to "void passfunc(lazy void function(string) f)" I

Re: Cancelling a stdin.read?

2016-04-10 Thread hilop via Digitalmars-d-learn
On Sunday, 10 April 2016 at 08:29:22 UTC, Lass Safin wrote: I have a multi-threaded program, one thread drawing to a window and handling it, the other handling stdin. [...] The external program that writes to the input has to close it when it has finished to write.

Re: Set cursor position in a file

2016-04-10 Thread Lucien via Digitalmars-d-learn
On Sunday, 10 April 2016 at 16:46:02 UTC, deed wrote: On Sunday, 10 April 2016 at 16:19:51 UTC, Lucien wrote: Hello, Is there the possibility to set the cursor position in a file ? Example: void main() { File myFile = File("myFile.txt"); showFile(myFile); // set

Internal compiler erorr

2016-04-10 Thread Eric via Digitalmars-d-learn
I am getting this error when I compile: Error: Internal Compiler Error: unsupported type const(string) No line number is given. Does anyone know what causes this? compiler version = v2.071.0 -Eric

Re: Set cursor position in a file

2016-04-10 Thread deed via Digitalmars-d-learn
On Sunday, 10 April 2016 at 16:19:51 UTC, Lucien wrote: Hello, Is there the possibility to set the cursor position in a file ? Example: void main() { File myFile = File("myFile.txt"); showFile(myFile); // set cursor pos to 0 showFile(myFile); } void

Set cursor position in a file

2016-04-10 Thread Lucien via Digitalmars-d-learn
Hello, Is there the possibility to set the cursor position in a file ? Example: void main() { File myFile = File("myFile.txt"); showFile(myFile); // set cursor pos to 0 showFile(myFile); } void showFile(File f) { while (!f.eof()) { write(f.readln()); }

Re: version pairs?

2016-04-10 Thread hilop via Digitalmars-d-learn
On Sunday, 10 April 2016 at 13:58:17 UTC, Jay Norwood wrote: Seems like there should be an extra level to the version statement, something like version(arch,x86). I must be missing something about the intended use of the version statement. This will never be done. The language creator has

version pairs?

2016-04-10 Thread Jay Norwood via Digitalmars-d-learn
Seems like there should be an extra level to the version statement, something like version(arch,x86). I must be missing something about the intended use of the version statement.

Dub and derelict-allegro5 "Could not find a valid dependency tree configuration"

2016-04-10 Thread Pedro Lopes via Digitalmars-d-learn
Hello, Every time I try to run a project with derelict-allegro5 package as a dependency, dub says: "Could not find a valid dependency tree configuration" I already cleaned the dub cache, that does not solve it, allegro package is installed (from alleg.sourceforge.net). dub works with

mov reg,0 vs xor reg,reg in core.atomic ?

2016-04-10 Thread darat via Digitalmars-d-learn
Is there a particular reason explaining why mov reg,0 is used and not xor reg,reg ? (or even and reg, 0) for example here: https://github.com/D-Programming-Language/druntime/blob/master/src/core/atomic.d#L1009 It seems that in Go too mov is used:

Re: execute bash?

2016-04-10 Thread wobbles via Digitalmars-d-learn
On Sunday, 10 April 2016 at 00:47:28 UTC, Puming wrote: On Saturday, 9 April 2016 at 08:56:17 UTC, wobbles wrote: On Friday, 8 April 2016 at 23:06:06 UTC, Puming wrote: On Friday, 8 April 2016 at 18:23:32 UTC, wobbles wrote: On Friday, 8 April 2016 at 16:07:13 UTC, Adam D. Ruppe wrote: On

Re: Correct way to spawn many and stoping when one finishes ?

2016-04-10 Thread klimp via Digitalmars-d-learn
On Sunday, 10 April 2016 at 07:48:51 UTC, klimp wrote: Is this corrrect ? Each task searches for the same thing so when once has found the others don't need to run anymore. It looks a bit strange not to stop those who havent find the thing: Actually I have to kill the other tasks, in this

Cancelling a stdin.read?

2016-04-10 Thread Lass Safin via Digitalmars-d-learn
I have a multi-threaded program, one thread drawing to a window and handling it, the other handling stdin. The thread which handles stdin is something like this: char[] buf; while(true) { readln(buf); } The window thread also has to receive close-events from the OS, such as when the

Correct way to spawn many and stoping when one finishes ?

2016-04-10 Thread klimp via Digitalmars-d-learn
Is this corrrect ? Each task searches for the same thing so when once has found the others don't need to run anymore. It looks a bit strange not to stop those who havent find the thing: import std.concurrency, core.thread, std.random; void task() { size_t i; while (true) {

Re: Stupid question about AA. The following code works but I don't undrstand why?!

2016-04-10 Thread Uranuz via Digitalmars-d-learn
On Saturday, 9 April 2016 at 21:16:08 UTC, ag0aep6g wrote: On Saturday, 9 April 2016 at 19:31:31 UTC, Uranuz wrote: I think that we need to add warning about such case in documentation section: https://dlang.org/spec/hash-map.html#construction_and_ref_semantic in order to prevent this kind of