Re: What parser generator can let me run arbitrary code in its match rules?

2023-11-20 Thread Julian Fondren via Digitalmars-d-learn
On Monday, 20 November 2023 at 23:50:24 UTC, Dmitry Ponyatov wrote: - not abandoned years ago - documentation and commented samples presenets - CTFE the best https://code.dlang.org/packages/pegged

Re: What parser generator can let me run arbitrary code in its match rules?

2023-11-20 Thread Guillaume Piolat via Digitalmars-d-learn
On Monday, 20 November 2023 at 23:56:36 UTC, Dmitry Ponyatov wrote: Or maybe someone advice me some set of books deeply targets for learning of binary and symmetric parsing (such as binpac), DCG in C or using generators in D, etc to let me write my own lib. 'Crafting Interpreters' book explain

Re: What parser generator can let me run arbitrary code in its match rules?

2023-11-20 Thread Dmitry Ponyatov via Digitalmars-d-learn
Or maybe someone advice me some set of books deeply targets for learning of binary and symmetric parsing (such as binpac), DCG in C or using generators in D, etc to let me write my own lib. Everething I found (besides the Dragon book) uses black magic with Haskell, Lisp etc.

What parser generator can let me run arbitrary code in its match rules?

2023-11-20 Thread Dmitry Ponyatov via Digitalmars-d-learn
- not abandoned years ago - documentation and commented samples presenets - CTFE the best

Re: What is :-) ?

2023-11-20 Thread Julian Fondren via Digitalmars-d-learn
On Monday, 20 November 2023 at 16:09:33 UTC, Antonio wrote: **Why this is a function and not a delegate?** ```auto createCounter = (int nextValue) => (int dummy) => nextValue++;``` Syntactically I dont see any difference: `createCounter` is a function, and not a delegate, as it doesn't clo

Re: What is :-) ?

2023-11-20 Thread Paul Backus via Digitalmars-d-learn
On Monday, 20 November 2023 at 16:09:33 UTC, Antonio wrote: What "breaks" my mind is that a compiler decision (treat a piece of code as function or delegate) is not completely transparent causing "side" effects on your code (writeln doesn't work the same way: it shows the delegate signature,

Re: What is :-) ?

2023-11-20 Thread evilrat via Digitalmars-d-learn
On Monday, 20 November 2023 at 16:09:33 UTC, Antonio wrote: Is there any way to force D compiler to treat this "createCounter" declaration as **delegate** instead of **function**? ```d auto createCounter = (int nextValue) => () => nextValue++; ``` generally there is a way to tell the com

Re: What is :-) ?

2023-11-20 Thread Antonio via Digitalmars-d-learn
On Monday, 20 November 2023 at 13:25:48 UTC, Paul Backus wrote: On Monday, 20 November 2023 at 08:47:34 UTC, Antonio wrote: - What is the way to do ```writeln``` work with ```Counter``` function the same way it works with ```next``` function? `writeln(&Counter)` should do it. It does not do

Re: What is :-) ?

2023-11-20 Thread Paul Backus via Digitalmars-d-learn
On Monday, 20 November 2023 at 08:47:34 UTC, Antonio wrote: - What is the way to do ```writeln``` work with ```Counter``` function the same way it works with ```next``` function? `writeln(&Counter)` should do it.

Re: What is :-) ?

2023-11-20 Thread Paul Backus via Digitalmars-d-learn
On Monday, 20 November 2023 at 08:47:34 UTC, Antonio wrote: I understand the problem with UFCS (``next`` is not using UFCS because it is a delegate defined in the own main() function, and ``Counter``` without () is treated as a function call because it is UFCS eligible ) This is not UFCS, it

Re: What is :-) ?

2023-11-20 Thread evilrat via Digitalmars-d-learn
On Monday, 20 November 2023 at 09:44:32 UTC, Antonio wrote: - Why writeln doesn't treat ```next``` and ```Counter``` the same way? (I think I understand why, but it shows a "low" level difference of something that syntactically is equivalent) - What is the way to show Counter signature usin

Re: What is :-) ?

2023-11-20 Thread Antonio via Digitalmars-d-learn
On Monday, 20 November 2023 at 09:11:07 UTC, evilrat wrote: if you meant to take the function/delegate and not invoke try `&Counter` instead, otherwise it expects the parameters. If you execute ``` writeln( "'Counter' is ", &Counter ); ``` It shows the Counter address: ``` 'Counter' is 557F

Re: What is :-) ?

2023-11-20 Thread evilrat via Digitalmars-d-learn
On Monday, 20 November 2023 at 08:47:34 UTC, Antonio wrote: Now, I uncomment the ```writeln( "'Counter' is ", Counter );``` line and compiler says ``` /home/antonio/Devel/topbrokers/whatsapp-srv/admin/x.d(12): Error: function `x.Counter(int nextValue)` is not callable using argument types `

What is :-) ?

2023-11-20 Thread Antonio via Digitalmars-d-learn
If I run this code ```d import std.stdio; void main(){ auto next = Counter(10); next().writeln; next().writeln; next().writeln; // What is "next" function? writeln( "'next' is ", next ); // What is "Counter" function? This fails // writeln( "'Counter' is ", Counter ); } auto

Re: cannot find source code for runtime library file 'object.d'

2023-11-20 Thread thinkunix via Digitalmars-d-learn
denis via Digitalmars-d-learn wrote: ``` $ zypper install dmd $ dmd main.d Error: cannot find source code for runtime library file 'object.d'    dmd might not be correctly installed. Run 'dmd -man' for installation instructions.    config file: /etc/dmd.conf I would say the package