Re: Using multiple mixin templates to implement operator overloading

2020-12-12 Thread Paul Backus via Digitalmars-d-learn
On Saturday, 12 December 2020 at 20:25:48 UTC, Adam D. Ruppe wrote: On Saturday, 12 December 2020 at 18:14:31 UTC, Paul Backus wrote: IMO this is one of the stupider design decisions in D, but it's unlikely it will ever be fixed. It is useful in several other contexts though, including user

Re: Writing a really fast lexer

2020-12-12 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Saturday, 12 December 2020 at 18:15:11 UTC, vnr wrote: Yes, I know Pegged, it's a really interesting parser generator engine, nevertheless, the grammar of what I would like to analyse is not a PEG. But I am also curious to know the performances of this tool for very large inputs. The

Re: Using multiple mixin templates to implement operator overloading

2020-12-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 12 December 2020 at 20:26:00 UTC, Dennis wrote: If issue 19365 got fixed eeek I thought that was fixed but apparently not :( so yeah alias won't work for operator overloads. Does work for other functions so good technique to know but not here. So for op prolly go with the

Re: Using multiple mixin templates to implement operator overloading

2020-12-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 12 December 2020 at 18:14:31 UTC, Paul Backus wrote: IMO this is one of the stupider design decisions in D, but it's unlikely it will ever be fixed. It is useful in several other contexts though, including user overriding and private data stores for the mixin. The easiest

Re: Using multiple mixin templates to implement operator overloading

2020-12-12 Thread Dennis via Digitalmars-d-learn
On Saturday, 12 December 2020 at 18:14:31 UTC, Paul Backus wrote: IMO this is one of the stupider design decisions in D, but it's unlikely it will ever be fixed. The easiest workaround is to use string mixins instead, which work the way you'd expect them to. If issue 19365 got fixed, it

Re: Writing a really fast lexer

2020-12-12 Thread Bastiaan Veelo via Digitalmars-d-learn
On Saturday, 12 December 2020 at 18:15:11 UTC, vnr wrote: On Saturday, 12 December 2020 at 16:43:43 UTC, Bastiaan Veelo wrote: Have you looked at Pegged [1]? It will give you the lexer and parser in one go. I'd be very interested to see how it performs on that kind of input. -- Bastiaan.

Re: Using multiple mixin templates to implement operator overloading

2020-12-12 Thread Tobias Pankrath via Digitalmars-d-learn
On Saturday, 12 December 2020 at 18:14:31 UTC, Paul Backus wrote: Functions from different mixin templates can't overload each other. The reason for this is that, when you mix in a mixin template, it does not *actually* add the declarations inside it to a current scope: instead, it adds them

Re: Writing a really fast lexer

2020-12-12 Thread vnr via Digitalmars-d-learn
On Saturday, 12 December 2020 at 16:43:43 UTC, Bastiaan Veelo wrote: On Friday, 11 December 2020 at 19:49:12 UTC, vnr wrote: For a project with good performance, I would need to be able to analyse text. To do so, I would write a parser by hand using the recursive descent algorithm, based on a

Re: Writing a really fast lexer

2020-12-12 Thread vnr via Digitalmars-d-learn
On Friday, 11 December 2020 at 20:19:49 UTC, H. S. Teoh wrote: On Fri, Dec 11, 2020 at 07:49:12PM +, vnr via Digitalmars-d-learn wrote: [...] If you want a *really* fast lexer, I recommend using GNU Flex (https://github.com/westes/flex/). Unfortunately, AFAIK it does not support D

Re: Using multiple mixin templates to implement operator overloading

2020-12-12 Thread Paul Backus via Digitalmars-d-learn
On Saturday, 12 December 2020 at 17:36:57 UTC, Tobias Pankrath wrote: I want to wrap e.g. an int and implement basic arithmetic. In the provided example [1] I use two mixin templates to separately implement scaling (multiplication with int/double) and addition and subtraction with the type

Using multiple mixin templates to implement operator overloading

2020-12-12 Thread Tobias Pankrath via Digitalmars-d-learn
I want to wrap e.g. an int and implement basic arithmetic. In the provided example [1] I use two mixin templates to separately implement scaling (multiplication with int/double) and addition and subtraction with the type itself. In the end I want to have several distinct wrappers and allow

Re: Writing a really fast lexer

2020-12-12 Thread Bastiaan Veelo via Digitalmars-d-learn
On Friday, 11 December 2020 at 19:49:12 UTC, vnr wrote: For a project with good performance, I would need to be able to analyse text. To do so, I would write a parser by hand using the recursive descent algorithm, based on a stream of tokens. I started writing a lexer with the d-lex package

Re: Need help to find source file location by PC address

2020-12-12 Thread Calvin P via Digitalmars-d-learn
On Saturday, 12 December 2020 at 15:51:46 UTC, Calvin P wrote: I made a cross build with LDC -g -gdwarf-4 -O0 -D_DEBUG, the app crash with a report include PC address 0x005e34a9. [...] Find the solution: lldb-11 tests_curl (lldb) target create "tests_curl" Current executable set to

Need help to find source file location by PC address

2020-12-12 Thread Calvin P via Digitalmars-d-learn
I made a cross build with LDC -g -gdwarf-4 -O0 -D_DEBUG, the app crash with a report include PC address 0x005e34a9. Is there a way to find the source location for that PC address? ==4172==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x035dfcf0 at pc 0x005e34a9 bp 0x035dfa20 sp

Re: dub: standard project: how to build the unittest (the thing `dub test` runs)

2020-12-12 Thread Andre Pany via Digitalmars-d-learn
On Saturday, 12 December 2020 at 12:47:59 UTC, Tobias Pankrath wrote: On Saturday, 12 December 2020 at 12:18:47 UTC, Andre Pany wrote: In any case you should have configurations in your dub json. Thank you for your detailed reply and I am sure I can make it work in the way you described.

Re: Can I convert string to expression somehow?

2020-12-12 Thread Godnyx via Digitalmars-d-learn
On Saturday, 12 December 2020 at 11:03:06 UTC, Tobias Pankrath wrote: On Saturday, 12 December 2020 at 09:05:19 UTC, Godnyx wrote: I'm trying to create a cool function that will let us do formatting sorter and faster. The function will work like that: outln("My name is {name} and my age is

Re: regex: ] in a character class

2020-12-12 Thread Tobias Pankrath via Digitalmars-d-learn
On Saturday, 12 December 2020 at 12:03:49 UTC, kdevel wrote: I don't have a suggestion for better wording yet. [1] https://dlang.org/phobos/std_regex.html This [1] is how I would word it. [1] https://github.com/dlang/phobos/pull/7724

Re: regex: ] in a character class

2020-12-12 Thread Tobias Pankrath via Digitalmars-d-learn
On Saturday, 12 December 2020 at 12:03:49 UTC, kdevel wrote: In some situations a ] must be escaped as in auto re = regex(`^[a\]]$`); // match a and ] only Unfortunately dmd/phobos does not warn if you forget the backslash: auto re = regex(`^[a]]$`); // match a] This leads me to the

Re: dub: standard project: how to build the unittest (the thing `dub test` runs)

2020-12-12 Thread Tobias Pankrath via Digitalmars-d-learn
On Saturday, 12 December 2020 at 12:18:47 UTC, Andre Pany wrote: In any case you should have configurations in your dub json. Thank you for your detailed reply and I am sure I can make it work in the way you described. But I don't think my use case is invalid and dub should improve its

Re: dub: standard project: how to build the unittest (the thing `dub test` runs)

2020-12-12 Thread Andre Pany via Digitalmars-d-learn
On Saturday, 12 December 2020 at 12:18:47 UTC, Andre Pany wrote: On Saturday, 12 December 2020 at 11:13:45 UTC, Tobias Pankrath wrote: [...] In any case you should have configurations in your dub json. For the first configuration, the name does not matter, it is used by default for command

Re: dub: standard project: how to build the unittest (the thing `dub test` runs)

2020-12-12 Thread Andre Pany via Digitalmars-d-learn
On Saturday, 12 December 2020 at 11:13:45 UTC, Tobias Pankrath wrote: Whenever I come back to some D, I seem to be stumbling over dub. Somehow dub and I don't align: $ dub init dubtest && cd dubtest $ dub test -> creates executable `dubtest` (saying Falling back to "dub -b unittest".) $

regex: ] in a character class

2020-12-12 Thread kdevel via Digitalmars-d-learn
In some situations a ] must be escaped as in auto re = regex(`^[a\]]$`); // match a and ] only Unfortunately dmd/phobos does not warn if you forget the backslash: auto re = regex(`^[a]]$`); // match a] This leads me to the documentation [1] which says \c where c is one of [|*+?()

dub: standard project: how to build the unittest (the thing `dub test` runs)

2020-12-12 Thread Tobias Pankrath via Digitalmars-d-learn
Whenever I come back to some D, I seem to be stumbling over dub. Somehow dub and I don't align: $ dub init dubtest && cd dubtest $ dub test -> creates executable `dubtest` (saying Falling back to "dub -b unittest".) $ touch source/lib.d dub test -> creates executable dubtest-test-library

Re: Can I convert string to expression somehow?

2020-12-12 Thread Tobias Pankrath via Digitalmars-d-learn
On Saturday, 12 December 2020 at 09:05:19 UTC, Godnyx wrote: I'm trying to create a cool function that will let us do formatting sorter and faster. The function will work like that: outln("My name is {name} and my age is {age}"); this will be equivalent to: writeln("My name is ", name, " and

Can I convert string to expression somehow?

2020-12-12 Thread Godnyx via Digitalmars-d-learn
I'm trying to create a cool function that will let us do formatting sorter and faster. The function will work like that: outln("My name is {name} and my age is {age}"); this will be equivalent to: writeln("My name is ", name, " and my age is ", age); or: writefln("My name is %s and my age