How do I write a "lexer or parser generators"

2014-01-23 Thread OP
I'd like Walter to reply to this. In his article here http://www.drdobbs.com/architecture-and-design/so-you-want-to-write-your-own-language/240165488 Walter says Somewhat more controversial, I wouldn't bother wasting time with lexer or parser generators and other so-called "compiler compilers

Re: How do I write a "lexer or parser generators"

2014-01-23 Thread Paulo Pinto
On Thursday, 23 January 2014 at 08:12:08 UTC, OP wrote: I'd like Walter to reply to this. In his article here http://www.drdobbs.com/architecture-and-design/so-you-want-to-write-your-own-language/240165488 Walter says Somewhat more controversial, I wouldn't bother wasting time with lexer or p

Re: DMD via MacPorts has a problem

2014-01-23 Thread Jacob Carlborg
On 2014-01-22 19:20, Russel Winder wrote: libphobos2.a is not compiled with PIC code on Linux and OSX so is not usable for creating shared libraries, it has to be libphobos.so. PIC is the default on OS X. But as David said, dynamic libraries are not properly implemented on OS X yet in DMD (or

Re: How do I write a "lexer or parser generators"

2014-01-23 Thread Daniel Murphy
"OP" wrote in message news:qtjpbqxlabjerowdl...@forum.dlang.org... I just looked at parse.c and I had no idea there is a precedence table. Why is there one rather than it being embedded like a switch statement which tries to handle all the higher precedence operations calling a function runnin

Re: How do I write a "lexer or parser generators"

2014-01-23 Thread Timon Gehr
On 01/23/2014 10:06 AM, Daniel Murphy wrote: "OP" wrote in message news:qtjpbqxlabjerowdl...@forum.dlang.org... I just looked at parse.c and I had no idea there is a precedence table. Why is there one rather than it being embedded like a switch statement which tries to handle all the higher prec

Re: How do I write a "lexer or parser generators"

2014-01-23 Thread Timon Gehr
On 01/23/2014 09:12 AM, OP wrote: Taking the syntax below I'm not sure how to fork a state and discard the invalid one. foo[5] = var2 foo[5] foo = var2 Here when I see foo[5] I'm either accessing an array (first statement) or declaring variables as an array of 5 elements (second statement). J

Re: package.d behavior

2014-01-23 Thread Leandro Motta Barros
Hi, Do anyone has any feedback about his issue? I (and at least one more user) believe that the "package.d" feature behaves strangely (please, see the examples in my original post). Thanks a lot, LMB PS: I am not a big fan of "bump" posts, but I believe this message may have been ignored given

Re: GPGPUs

2014-01-23 Thread Paulo Pinto
On Wednesday, 22 January 2014 at 15:26:26 UTC, Ola Fosheim Grøstad wrote: On Wednesday, 22 January 2014 at 15:21:37 UTC, Ola Fosheim Grøstad wrote: source-code and the runtime can do the rest. But hide it so well that it makes sense to write generic DMD code this way. You might want to generat

symmetric signed types

2014-01-23 Thread Dominikus Dittes Scherkl
There is one mistake in C that D proliverates: The T.min value of signed types. e.g. byte a = -128; auto b = -a; What type should b get? (of course "byte" but the value doesn't fit!) Also getting the absolute value of some signed variable need to return a different type or doesn't work corr

Template specialization

2014-01-23 Thread Daniel Kozak
import std.stdio; class D : X{} class X{} template t1(T : void function(T)){enum t1 = "1.";} template t1(T : void function(X)){enum t1 = "2.";} int main(string[] argv){ t1!(void function(D)).writeln(); readln(); return 0; } this code prints 1. on dmd and gdc but on ldc it prints

Re: How do I write a "lexer or parser generators"

2014-01-23 Thread Boyd
On Thursday, 23 January 2014 at 08:12:08 UTC, OP wrote: I'd like Walter to reply to this. In his article here http://www.drdobbs.com/architecture-and-design/so-you-want-to-write-your-own-language/240165488 Walter says Somewhat more controversial, I wouldn't bother wasting time with lexer or p

Re: symmetric signed types

2014-01-23 Thread bearophile
Dominikus Dittes Scherkl: E.g. "ubyte abs(byte)" - this functions which can't even use a template, or has anybody a good idea ho to express "unsigned T abs(T)(T x)"? I think this is not hard to do in D. by the way: why wasn't "short" instead called "word"? On most modern CPUs a word is l

Re: Template specialization

2014-01-23 Thread Timon Gehr
On 01/23/2014 01:44 PM, Daniel Kozak wrote: import std.stdio; class D : X{} class X{} template t1(T : void function(T)){enum t1 = "1.";} template t1(T : void function(X)){enum t1 = "2.";} int main(string[] argv){ t1!(void function(D)).writeln(); readln(); return 0; } this cod

Re: Template specialization

2014-01-23 Thread Daniel Kozák
Timon Gehr píše v Čt 23. 01. 2014 v 15:42 +0100: > On 01/23/2014 01:44 PM, Daniel Kozak wrote: > > import std.stdio; > > > > class D : X{} > > > > class X{} > > > > > > template t1(T : void function(T)){enum t1 = "1.";} > > template t1(T : void function(X)){enum t1 = "2.";} > > > > int main(string[

Re: Should this work?

2014-01-23 Thread Regan Heath
On Wed, 22 Jan 2014 19:39:14 -, Andrei Alexandrescu wrote: On 1/13/14 4:53 AM, Regan Heath wrote: On Fri, 10 Jan 2014 16:30:12 -, Andrei Alexandrescu wrote: The way I see it one learns a name for an algorithm (low cognitive load) and then uses it everywhere. This is not Go. Sure.

Re: Review of std.signal

2014-01-23 Thread Martin Nowak
On 01/06/2014 11:39 AM, Dicebot wrote: =/ Any good idea to make those more visible? Maybe we should setup a mailing list for those who want to be notified about ongoing reviews? Yes, a separate newsgroup would help here. Do you have an idea for a name? digitalmars.D.phobos or digitalmars.D.revi

Re: Review of std.signal

2014-01-23 Thread Martin Nowak
On 01/07/2014 09:18 AM, Robert wrote: I did, but there are still some bugs with template mixins, which finally drove me to a string mixin and in the end I liked it better. Please file any bugs you encounter (https://d.puremagic.com/issues/). Most bugs can be minimized automatically using dustm

Re: symmetric signed types

2014-01-23 Thread Dominikus Dittes Scherkl
On Thursday, 23 January 2014 at 14:40:58 UTC, bearophile wrote: Dominikus Dittes Scherkl: E.g. "ubyte abs(byte)" - this functions which can't even use a template, or has anybody a good idea ho to express "unsigned T abs(T)(T x)"? I think this is not hard to do in D. Not hard. But very ugly.

Re: symmetric signed types

2014-01-23 Thread Stanislav Blinov
On Thursday, 23 January 2014 at 12:09:24 UTC, Dominikus Dittes Scherkl wrote: Also getting the absolute value of some signed variable need to return a different type or doesn't work correct for all input. E.g. "ubyte abs(byte)" - this functions which can't even use a template, or has anybody

Re: symmetric signed types

2014-01-23 Thread Dominikus Dittes Scherkl
On Thursday, 23 January 2014 at 16:52:14 UTC, Stanislav Blinov wrote: On Thursday, 23 January 2014 at 12:09:24 UTC, Dominikus Dittes Scherkl wrote: Also getting the absolute value of some signed variable need to return a different type or doesn't work correct for all input. E.g. "ubyte abs(by

Conflict with private symbol from an imported module

2014-01-23 Thread Nicolas Sicard
Hi, I known this has been discussed before, and there still is an open issue in bugzilla (https://d.puremagic.com/issues/show_bug.cgi?id=1238). Is it considered a feature or a bug? Thanks

Re: symmetric signed types

2014-01-23 Thread Stanislav Blinov
On Thursday, 23 January 2014 at 16:54:29 UTC, Dominikus Dittes Scherkl wrote: Cool. So why it that not used in std.math.abs? http://d.puremagic.com/issues/show_bug.cgi?id=8666 Andrei's comment sums it up pretty much. AFAIK there may also be some portability considertaions when performing ca

Re: Conflict with private symbol from an imported module

2014-01-23 Thread Adam D. Ruppe
I think it is one of the most major problems with the whole module system right now...

Symbol Undefined _EnumWindows@12

2014-01-23 Thread AntonSotov
hello. having trouble importing WinAPI function EnumWindows. example: //** module main; pragma(lib, "user32"); alias int function (void*, long) WNDENUMPROC; extern (Windows) int EnumWindows(WNDENUMPROC, long); //extern (Windows) void* CreateToolhelp32Snap

Re: Review of std.signal

2014-01-23 Thread Martin Nowak
On 01/06/2014 11:13 AM, Vladimir Panteleev wrote: IMO, the effort to disallow third parties to "emit" signals on your object by far exceeds its worth. For this purpose, you have needed: - string mixins - ...which declare, by convention, a field with a name not explicitly given by the user

Re: Symbol Undefined _EnumWindows@12

2014-01-23 Thread Daniel Murphy
"AntonSotov" wrote in message news:qyxvsktbxokfhwebg...@forum.dlang.org... extern (Windows) int EnumWindows(WNDENUMPROC, long); The second argument is LPARAM, which maps to C's long, but D's long maps to C's long long. To be safe, use these aliases whenever possible by using: import core.s

Re: Symbol Undefined _EnumWindows@12

2014-01-23 Thread Adam D. Ruppe
On Thursday, 23 January 2014 at 17:22:55 UTC, AntonSotov wrote: alias int function (void*, long) WNDENUMPROC; extern (Windows) int EnumWindows(WNDENUMPROC, long); These shouldn't be longs. You could call them LPARAM (import core.sys.windows.windows) or int. A "long" in C is actually an "int

Re: Conflict with private symbol from an imported module

2014-01-23 Thread Gary Willoughby
On Thursday, 23 January 2014 at 17:06:17 UTC, Nicolas Sicard wrote: Hi, I known this has been discussed before, and there still is an open issue in bugzilla (https://d.puremagic.com/issues/show_bug.cgi?id=1238). Is it considered a feature or a bug? Thanks Modules are broken in several way

Re: Conflict with private symbol from an imported module

2014-01-23 Thread Nicolas Sicard
On Thursday, 23 January 2014 at 17:29:08 UTC, Gary Willoughby wrote: On Thursday, 23 January 2014 at 17:06:17 UTC, Nicolas Sicard wrote: Hi, I known this has been discussed before, and there still is an open issue in bugzilla (https://d.puremagic.com/issues/show_bug.cgi?id=1238). Is it consi

Re: Conflict with private symbol from an imported module

2014-01-23 Thread H. S. Teoh
On Thu, Jan 23, 2014 at 05:38:03PM +, Nicolas Sicard wrote: > On Thursday, 23 January 2014 at 17:29:08 UTC, Gary Willoughby wrote: > >On Thursday, 23 January 2014 at 17:06:17 UTC, Nicolas Sicard > >wrote: > >>Hi, > >> > >>I known this has been discussed before, and there still is an > >>open is

Re: Conflict with private symbol from an imported module

2014-01-23 Thread Paulo Pinto
Am 23.01.2014 19:16, schrieb H. S. Teoh: On Thu, Jan 23, 2014 at 05:38:03PM +, Nicolas Sicard wrote: On Thursday, 23 January 2014 at 17:29:08 UTC, Gary Willoughby wrote: On Thursday, 23 January 2014 at 17:06:17 UTC, Nicolas Sicard wrote: Hi, I known this has been discussed before, and the

Re: Review of std.signal

2014-01-23 Thread Dicebot
On Thursday, 23 January 2014 at 16:17:38 UTC, Martin Nowak wrote: On 01/06/2014 11:39 AM, Dicebot wrote: =/ Any good idea to make those more visible? Maybe we should setup a mailing list for those who want to be notified about ongoing reviews? Yes, a separate newsgroup would help here. Do you

Re: Conflict with private symbol from an imported module

2014-01-23 Thread Dicebot
There is a pull from Martin that implements new symbol access resolution rules and old DIP of mine on same topic. Those do contradict each other though as we seem to disagree on quite on rules related to template instances / alias arguments. Martin has the obvious benefit of actually having an

Re: int** should be compatible to void**?

2014-01-23 Thread Ali Çehreli
On 01/22/2014 01:25 AM, Katayama Hirofumi MZ wrote: > Oh, I see. Thanks, Kenji san. Going off topic, that answers a question of mine! :) I could not be sure whether Kenji san, Hara san, or even Hara-san would be correct when I wrote to a Japanese person. Ali P.S. Going even more off topic,

Re: int** should be compatible to void**?

2014-01-23 Thread Stanislav Blinov
On Thursday, 23 January 2014 at 19:00:45 UTC, Ali Çehreli wrote: P.S. Going even more off topic, that person did not respond to my email yet. ;) Maybe you actually did get it wrong? :)

Re: int** should be compatible to void**?

2014-01-23 Thread Jakob Ovrum
On Thursday, 23 January 2014 at 19:00:45 UTC, Ali Çehreli wrote: On 01/22/2014 01:25 AM, Katayama Hirofumi MZ wrote: > Oh, I see. Thanks, Kenji san. Going off topic, that answers a question of mine! :) I could not be sure whether Kenji san, Hara san, or even Hara-san would be correct when I w

Re: Symbol Undefined _EnumWindows@12

2014-01-23 Thread Jacob Carlborg
On 2014-01-23 18:27, Adam D. Ruppe wrote: These shouldn't be longs. You could call them LPARAM (import core.sys.windows.windows) or int. A "long" in C is actually an "int" in D. D's "long" is more like C's "long long". A "long" in C is actually a D "int" on Windows. On Posix it's a D "int" w

Re: int** should be compatible to void**?

2014-01-23 Thread Ali Çehreli
On 01/23/2014 11:09 AM, Stanislav Blinov wrote: On Thursday, 23 January 2014 at 19:00:45 UTC, Ali Çehreli wrote: P.S. Going even more off topic, that person did not respond to my email yet. ;) Maybe you actually did get it wrong? :) I hope not. :) Ali

Re: Review of std.signal

2014-01-23 Thread Jacob Carlborg
On 2014-01-23 19:26, Dicebot wrote: digitalmars.D.review is better. We only review Phobos module that way now but it can be extended. Related offtopic: I wonder sometimes if it can/should be generalized for any important decision making involving community. Currently only Phobos reviews live w

Re: GPGPUs

2014-01-23 Thread Ben Cumming
On Thursday, 23 January 2014 at 11:50:19 UTC, Paulo Pinto wrote: Why not just generate SPIR, HSAIL or PTX code instead ? -- Paulo We advertised an internship at my work to look at using D for GPUs in HPC (I work at the Swiss National Supercomputing Centre, which recently acquired are rather

Re: GPGPUs

2014-01-23 Thread Ben Cumming
On Thursday, 23 January 2014 at 19:34:06 UTC, Ben Cumming wrote: The LLVM backend supports PTX generation, and Clang has full support for OpenGL. I mean OpenCL, not OpenGL.

Re: GPGPUs

2014-01-23 Thread Paulo Pinto
Am 23.01.2014 20:34, schrieb Ben Cumming: On Thursday, 23 January 2014 at 11:50:19 UTC, Paulo Pinto wrote: Why not just generate SPIR, HSAIL or PTX code instead ? -- Paulo We advertised an internship at my work to look at using D for GPUs in HPC (I work at the Swiss National Supercomputing C

Re: GPGPUs

2014-01-23 Thread Ben Cumming
On Thursday, 23 January 2014 at 20:05:28 UTC, Paulo Pinto wrote: I still like C++, but with C++14 and whatever might come in C++17 it might just be too much for any sane developer. :\ I enjoy C++ metaprogramming too, but it is often a chore. And I don't want to wait until 2017! I'll pa

Re: symmetric signed types

2014-01-23 Thread Andrei Alexandrescu
On 1/23/14 4:09 AM, Dominikus Dittes Scherkl wrote: There is one mistake in C that D proliverates: The T.min value of signed types. e.g. byte a = -128; auto b = -a; What type should b get? (of course "byte" but the value doesn't fit!) The type will be int. Also getting the absolute value

Re: Should this work?

2014-01-23 Thread Andrei Alexandrescu
On 1/23/14 8:06 AM, Regan Heath wrote: This. Not my position. Rather I am suggesting we identify individual omissions (like std.string.contains) and add an alias. So that people don't have to struggle quite so much when switching to D. The lower the bar and all that.. Ionno. Just look at th

Re: GPGPUs

2014-01-23 Thread Atila Neves
I did an internship at CERN during 2003-2004. Lots of interesting C++ being used there as well. Small world, we were at CERN at the same time. There's still a lot of "interesting" C++ going on there. I haven't worked there in 5 years but my girlfriend still does. What's worse is how "interesting

Re: GPGPUs

2014-01-23 Thread Paulo Pinto
Am 23.01.2014 22:20, schrieb Atila Neves: I did an internship at CERN during 2003-2004. Lots of interesting C++ being used there as well. Small world, we were at CERN at the same time. There's still a lot of "interesting" C++ going on there. I haven't worked there in 5 years but my girlfriend s

Re: Review of std.signal

2014-01-23 Thread robert
(https://vhios.dyndns.org/dlang.org/web/phobos/std_signal.html) Was outdated (web/phobos-prerelase/std_signal.html was current), but the old link you posted is now also up2date. Sorry for that. Best regards, Robert

Re: symmetric signed types

2014-01-23 Thread Walter Bright
On 1/23/2014 12:35 PM, Andrei Alexandrescu wrote: On 1/23/14 4:09 AM, Dominikus Dittes Scherkl wrote: What type should b get? (of course "byte" but the value doesn't fit!) The type will be int. As an aside, the C integral arithmetic rules are often criticized. However, nobody has found anot

Re: Review of std.signal

2014-01-23 Thread Martin Nowak
On 01/23/2014 07:26 PM, Dicebot wrote: I wonder sometimes if it can/should be generalized for any important decision making involving community. Currently only Phobos reviews live with their own somewhat independent life, everything else is process bottleneck mandating some intervention from smal

Re: Current state of "D as a better C" (Windows)?

2014-01-23 Thread Vladimir Panteleev
Hi Mike, thanks for the extensive reply. On Wednesday, 22 January 2014 at 04:13:41 UTC, Mike wrote: To paraphrase, if you really want the best of what D has to offer, you'll need to implement a good part of the runtime. But I argue, not all of it. Well, even C with D's metaprogramming would

Re: Current state of "D as a better C" (Windows)?

2014-01-23 Thread Vladimir Panteleev
On Wednesday, 22 January 2014 at 11:13:53 UTC, Kagamin wrote: On Wednesday, 22 January 2014 at 02:18:43 UTC, Vladimir Panteleev wrote: I've started a "framework" for this purpose a while ago[1], [...] A framework doesn't seem like a good idea. You can have either big framework or small execut

Re: Review of std.signal

2014-01-23 Thread Martin Nowak
On 01/11/2014 08:13 PM, Robert wrote: I agree. Is the only reason to have a weak connection? Yes. Weak connections are the only reason. Wouldn't it be possible to find out whether the delegate context ptr is actually an object? Not sure how to do it safely though and Interfaces slightly dif

Re: Review of std.signal

2014-01-23 Thread Martin Nowak
On 01/13/2014 10:16 PM, ilya-stromberg wrote: It's not so good to have array of delegates because you will have a memory leaks. Delegate has permanent pointer to the object, so GC will never free it. As alternative, you can delete delegate manually, but in this case you can have problems with ma

Re: Review of std.signal

2014-01-23 Thread Martin Nowak
On 01/23/2014 06:16 PM, Martin Nowak wrote: Of course there are a few implementation issues. - There is no WeakDelegate in druntime or phobos. Maybe requiring explicit disconnect is good enough? - The lifetime of the delegate context could be scoped. No idea how to solve this one, but yo

Re: Review of std.signal

2014-01-23 Thread ilya-stromberg
On Thursday, 23 January 2014 at 22:58:08 UTC, Martin Nowak wrote: On 01/13/2014 10:16 PM, ilya-stromberg wrote: It's not so good to have array of delegates because you will have a memory leaks. Delegate has permanent pointer to the object, so GC will never free it. As alternative, you can del

Re: symmetric signed types

2014-01-23 Thread bearophile
Walter Bright: The huge advantage of the C rules is they are very widely known, used, and understood. And following them allows me to translate intricate C code to D with less headaches. Still, Go has adopted a different strategy... Bye, bearophile

Re: Static Analysis Tooling / Effective D

2014-01-23 Thread Walter Bright
On 1/20/2014 8:34 PM, Brian Schott wrote: There's a small feature wishlist in the project's README, but I'd like to get some opinions from the newsgroup: What kinds of errors have you seen in your code that you think a static analysis tool could help with? Here's a great source of potential rul

Re: symmetric signed types

2014-01-23 Thread Walter Bright
On 1/23/2014 4:50 PM, bearophile wrote: Walter Bright: The huge advantage of the C rules is they are very widely known, used, and understood. And following them allows me to translate intricate C code to D with less headaches. Still, Go has adopted a different strategy... I know. 1. Go de

Re: symmetric signed types

2014-01-23 Thread bearophile
Walter Bright: 1. Go determines the type of (e1 op e2) as the type of the first operand. http://golang.org/ref/spec#Arithmetic_operators I consider this not only surprising (as we expect + to be commutative) but can lead to unexpected truncation, as in (byte = byte + int32). I don't kno

fullyQualifiedName fails on template

2014-01-23 Thread Øivind
Is fullyQualifiedName supposed to work on templates? The following fails: struct MsgPack(T ...) { } struct TestPoint { float x, y; } alias TestPack = MsgPack!TestPoint; void main() { import std.traits; import std.stdio; //writeln(fullyQualifiedName!

Re: package.d behavior

2014-01-23 Thread Jesse Phillips
On Thursday, 23 January 2014 at 11:43:07 UTC, Leandro Motta Barros wrote: Hi, Do anyone has any feedback about his issue? I (and at least one more user) believe that the "package.d" feature behaves strangely (please, see the examples in my original post). Thanks a lot, You should probably

Re: symmetric signed types

2014-01-23 Thread Walter Bright
On 1/23/2014 5:44 PM, bearophile wrote: So despite what the docs say, it seems the two types need to be the same for the sum to work? I was going by what the spec said. While this program compiles: package main import ("fmt") func main() { var x byte = 10; var y int = 1000;

Re: Current state of "D as a better C" (Windows)?

2014-01-23 Thread Mike
On Thursday, 23 January 2014 at 22:39:38 UTC, Vladimir Panteleev wrote: Well, even C with D's metaprogramming would be a big win. But picking-and-choosing runtime-supported features would be even better. Quite right! I have actually delayed implementing classes a little bit because I found I

Re: Abstract syntax tree manipulation

2014-01-23 Thread Suminda Dharmasena
Also Redex Racket / Racket can give some inspiration. Also perhaps Nimrod can get a D back end?