Re: Pegged v0.4: longest-match, left-recursion, and expandable parse trees

2017-03-03 Thread Philippe Sigaud via Digitalmars-d-announce
Thank you all for the positive comments!

Pegged v0.4: longest-match, left-recursion, and expandable parse trees

2017-03-02 Thread Philippe Sigaud via Digitalmars-d-announce
Hi, Pegged is a parser generator based on Parsing Expression Grammars (PEG) written in D, that aims to be both simple to use and work at compile-time. See: https://github.com/PhilippeSigaud/Pegged To use Pegged, just call the grammar function with a PEG and mix it in your module. For

Re: Regex in ctfe?

2016-01-31 Thread Philippe Sigaud via Digitalmars-d
On Tuesday, 26 January 2016 at 01:34:09 UTC, Manu wrote: Possible to std.regex in ctfe? (...) I have a string import destined for a mixin, and I want to parse it with regex, but I haven't been able to make it work. The docs mention nothing about this possibility. Hi Manu, a possible

Re: Reducing Pegged ASTs

2014-11-25 Thread Philippe Sigaud via Digitalmars-d-learn
On Tue, Nov 25, 2014 at 4:12 PM, Nordlöw digitalmars-d-learn@puremagic.com wrote: Is there a way to (on the fly) reduce Pegged parse results such as C [0, 6][int, x, ;] +-C.TranslationUnit [0, 6][int, x, ;] +-C.ExternalDeclaration [0, 6][int, x, ;] +-C.Declaration [0, 6][int, x,

Re: accessing numeric template parameters

2014-11-03 Thread Philippe Sigaud via Digitalmars-d-learn
On Mon, Nov 3, 2014 at 3:27 PM, Dominikus Dittes Scherkl via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: If I have a struct with numeric template parameter, how can I access it within member functions? Like normal member variables? And how about the constructor? struct

Re: how to expand tuple?

2014-11-02 Thread Philippe Sigaud via Digitalmars-d-learn
Any time you want to return or store a group of values of different types. In a way, tuples are just structs without a name (anonymous structs, if you will). Say you have function `foo' and want it to return an int and a string. In D, you cannot do: (int, string) foo() { ... return (3, abc);}

Re: how to expand tuple?

2014-11-01 Thread Philippe Sigaud via Digitalmars-d-learn
On Sat, Nov 1, 2014 at 9:34 PM, Suliman via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Few questions. 1. In examples tuples are created with keyword auto. Can I create them with another keyword. Or auto mean structure of data, that have not standard type like (int or

Re: how to expand tuple?

2014-11-01 Thread Philippe Sigaud via Digitalmars-d-learn
I thought you were expanding it Drat. *You* thought you were expanding it.

Re: D Parsing (again)/ D grammar

2014-10-03 Thread Philippe Sigaud via Digitalmars-d
Thanks a lot, by the way! I've just skimmed through the code and the README... You did not use the packed forest representation, did you..? Sorry for the microscopic documentation (Pegged is more documented than that...), it was a 'for me only' project. The forest is packed, in the sense

Re: D Parsing (again)/ D grammar

2014-10-03 Thread Philippe Sigaud via Digitalmars-d
Anyway, thank you very much for the code. The weekend is coming - I'll play with your implementation and see if there any improvements possible. Be sure to keep me informed of any enormous mistake I made. I tried Appender and other concatenation means, without big success. Btw, I saw on the ML

Re: D Parsing (again)/ D grammar

2014-10-02 Thread Philippe Sigaud via Digitalmars-d
Chances are that I will be able to get the original GLL parser generator from one of algorithm authors (Adrian Johnstone). He's really helpful here. From that point, I will only have to add a frontend for generating a concrete parser, starting with Python - it already has a fully working

Re: D Parsing (again)/ D grammar

2014-10-02 Thread Philippe Sigaud via Digitalmars-d
I did that during this summer, almost to the point it was self-sustained (that is, the GLL parser generator was used to generate a parser for grammars files). I chose a range interface: input is a string, the parse forest is output as a range of parse trees. Nice! Is it public? Github? No

Re: D Parsing (again)/ D grammar

2014-10-02 Thread Philippe Sigaud via Digitalmars-d
I have a huge collection of projects I never published :-) We all do, I guess. Oh, the ratio is more and 100 projects for one published... No, this is not exactly what I mean. Multithreading can be perfectly fine in some cases, very fruitful sometimes. Say, in NLP, when one has to process

Re: D Parsing (again)/ D grammar

2014-10-02 Thread Philippe Sigaud via Digitalmars-d
On Thu, Oct 2, 2014 at 11:19 PM, Vladimir Kazanov via Digitalmars-d digitalmars-d@puremagic.com wrote: Check the mailbox, Thank you I sent it to you. I was asleep, sorry :-)

Re: How to pack types with variables in one message to send it to another thread? [tuple]

2014-09-07 Thread Philippe Sigaud via Digitalmars-d-learn
You can also create new types: struct UseSprite { string s;} struct UseAnimation { string s;} It's not a class instance, it's a class type. Something like `cast(Sprite) null` in parameters. It can be replaced by string Sprite, but in this case I can't use receive() as it is. E.g.

Re: literate programming in D

2014-09-04 Thread Philippe Sigaud via Digitalmars-d-learn
Ah that sounds interesting too! Immediately I start thinking in terms like tidlywiki http://tiddlywiki.com/ or something similar, I guess the emacs way described earlier also would support this. I personally always enjoy reading the readthedocs stuff http://docs.readthedocs.org/en/latest/ is

Re: String to binary conversion

2014-09-03 Thread Philippe Sigaud via Digitalmars-d
On Wed, Sep 3, 2014 at 7:59 PM, Ali Çehreli digitalmars-d@puremagic.com wrote: Also, I've just noticed that Questions about learning D sounds a little off because it sounds as if the questions should be like how can I learn D. :) How about something like Questions when learning D. Or even:

Re: Daemonize v0.1 - simple way to create cross-platform daemons

2014-08-31 Thread Philippe Sigaud via Digitalmars-d-announce
Nice! I have a few questions/remarks, mainly to simplify the API somewhat. Please bear with me :-) // First you need to describe your daemon via template alias daemon = Daemon!( DaemonizeExample1, // unique name Does the user sees/uses this name in any way afterwards? Because I think you

Re: Daemonize v0.1 - simple way to create cross-platform daemons

2014-08-31 Thread Philippe Sigaud via Digitalmars-d-announce
Does the user sees/uses this name in any way afterwards? Because I think you could also produce a unique string at compile-time (by using __FILE__ and __LINE__, unless someone has a better idea), if the user does not provide one. Maybe he just wants an anonymous daemon, or doesn't care,

Re: Daemonize v0.1 - simple way to create cross-platform daemons

2014-08-31 Thread Philippe Sigaud via Digitalmars-d-announce
On Sun, Aug 31, 2014 at 11:36 PM, Meta via Digitalmars-d-announce digitalmars-d-announce@puremagic.com wrote: I didn't know you could have an enum and extend it with a cast like this. This is not a good thing. Enums are supposed to denote a *closed*, enumerated set of items. I agree. It's

Re: Daemonize v0.1 - simple way to create cross-platform daemons

2014-08-31 Thread Philippe Sigaud via Digitalmars-d-announce
I can (not must) have the form, the delegate params are tested independently from signal composition. OK, good. Is that the standard behavior for daemons in OSes? Most signals are simply ignored (except termination ones). I see. Some signals could be sent without any reason: sighup or

Re: Clojure transducers

2014-08-31 Thread Philippe Sigaud via Digitalmars-d
What is D's attitude toward this concept? Hickey's original announcement is also interesting to read. Elegant, as always. It seems to me that ranges and range algorithms in D already permit this composition of actions, without the creation of intermediate structures: import std.algorithm;

Re: How to build dlang.org dd files

2014-08-31 Thread Philippe Sigaud via Digitalmars-d-learn
dmd -c -o- macros.ddoc doc.ddoc -Df{ddoc_filename}.html {ddoc_filename}.dd If someone knows of a more official syntax, please let me know. I don't know of another syntax, but could you please put this somewhere on the wiki? Maybe in the cookbook section: http://wiki.dlang.org/Cookbook

Re: alias and mixin

2014-08-31 Thread Philippe Sigaud via Digitalmars-d-learn
It is basically just an annoying grammar limitation that does not allow to use mixin / __traits as an identifier. The usual helper template: ``` alias helper(alias a) = a; ``` helps for aliasing __traits and anonymous function templates (x = x+1), but I don't see an easy solution for

Re: alias and mixin

2014-08-31 Thread Philippe Sigaud via Digitalmars-d-learn
I recommend slightly more generic form: template Alias(T...) if (T.length == 1) { alias Alias = T[0]; } it is quite helpful in templated code to be able to alias _anything_ That's what I use also, but didn't want another thread on the (T...) if (T.length ==1) trick :) But

Re: literate programming in D

2014-08-30 Thread Philippe Sigaud via Digitalmars-d-learn
On Sat, Aug 30, 2014 at 1:37 AM, nikki wrote: I wasn't too happy about it and I wrote my own little parse thingie and have a literate version nice and meta and small and sloppy ;) http://nikkikoole.github.io/docs/dokidokDOC.html I use it to change my d sourcefile slightly (into valid

Re: literate programming in D

2014-08-30 Thread Philippe Sigaud via Digitalmars-d-learn
On Friday, 29 August 2014 at 23:58:19 UTC, Chris Cain wrote: I used https://www.npmjs.org/package/literate-programming (+ pandoc) to do this when writing https://dl.dropboxusercontent.com/u/2206555/uniformUpgrade.pdf in markdown. Do you remember if some snippets can be hidden in the final

Re: getting the adress of a function by its name in string format

2014-08-30 Thread Philippe Sigaud via Digitalmars-d-learn
instead I would like to use EAT_FOOD_DECISION and EAT_FOOD_BEHAVIOUR and get the functions? Is that possible somehow? If all your functions had the same signature, you could use an associative array FunctionType[string] and initialize it: FunctionType[string] myFuncs;

Re: Crazy code by Adam on SO

2014-08-29 Thread Philippe Sigaud via Digitalmars-d
http://stackoverflow.com/questions/2329/d-finding-all-functions-with-certain-attribute That's what a good part of his book is about, also. A nice read, one of my favorite chapters of the D Cookbook. Ideally, Adam should do a PR for Phobos to add some code-walking ability like this. I'm

Re: Crazy code by Adam on SO

2014-08-29 Thread Philippe Sigaud via Digitalmars-d
On Fri, Aug 29, 2014 at 7:12 PM, H. S. Teoh via Digitalmars-d digitalmars-d@puremagic.com wrote: The mixin(import ...) line was mind-blowingly ingenious, I have to say. I remember using the same 'module' trick a few years ago (that is, getting a name with __traits and testing whether it begins

Re: Crazy code by Adam on SO

2014-08-29 Thread Philippe Sigaud via Digitalmars-d
On Friday, 29 August 2014 at 17:29:34 UTC, H. S. Teoh via Digitalmars-d wrote: A lot of Adam's stuff are in that category. (...) I highly recommending studying how Adam's code achieves this. :-) It's also a bit hypnotic. I wanted to do a quick test of his simpledisplay.d module, after

Re: const after initialization / pointers, references and values

2014-08-21 Thread Philippe Sigaud via Digitalmars-d
On Wed, Aug 20, 2014 at 11:49 PM, Jakob Ovrum via Digitalmars-d digitalmars-d@puremagic.com wrote: Certainly the easiest, but I don't think it's always the best. If light-weightedness is desired, make the struct contain the reference, effectively making the struct a reference type Well, yes.

Re: const after initialization / pointers, references and values

2014-08-20 Thread Philippe Sigaud via Digitalmars-d
After initialization there is no need to modify the data anymore. My first question is: can the data be changed to const once initialized? You can have const or immutable data, that can be initialized once. I tend to use pure functions to do that: struct Node { Node[] block;

Re: Variadic parameter of length 1

2014-08-20 Thread Philippe Sigaud via Digitalmars-d-learn
On Wed, Aug 20, 2014 at 5:34 PM, Dominikus Dittes Scherkl via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Wednesday, 20 August 2014 at 15:26:14 UTC, monarch_dodra wrote: AFAIK, it's a historical workaround to accept T as either alias or not alias, as varargs have auto

Re: No Output with shebang.

2014-08-20 Thread Philippe Sigaud via Digitalmars-d-learn
gdc just compiles the program to a.out. It doesn't run the resulting executable. You need to use something like rdmd instead of gdc. rdmd compiles to some temporary location and then runs the executable. Wow, that was fast. Thanks a lot! Can compiler switches be used with the shebang

Re: Cross-Platform D

2014-08-19 Thread Philippe Sigaud via Digitalmars-d
On Tuesday, 19 August 2014 at 11:14:17 UTC, Vladimir Panteleev wrote: You realize you're replying to a decade-old post, right? What about storing D files on BETAMAX tapes? Oh, wait.

Re: Why does D rely on a GC?

2014-08-19 Thread Philippe Sigaud via Digitalmars-d
I won't look at it again for a different reason. They're the types that say A monad is just a monoid in the category of endofunctors, what's the problem? Sure, so one should point out that problem may be made out to be that the monoidal product [1][2] is underspecified for someone

Re: iterate traits ?

2014-08-19 Thread Philippe Sigaud via Digitalmars-d-learn
A foreach becomes compile-time whenever the aggregate is a purely compile- time construct such as a tuple. Yeah, I think you transformed it into a runtime array by using [ ... ]. Tuples with compatible types can be 'downgraded' to arrays that way. But there is no need to: tuples are iterable,

Re: @safe, pure and nothrow at the beginning of a module

2014-08-16 Thread Philippe Sigaud via Digitalmars-d-learn
If I understand correctly Adam Ruppe's Cookbook, by putting @safe: pure: nothrow: at the beginning of a module, I distribute it on all definitions, right? Even methods, inner classes, and so on? I read Adam's book again and I was wrong: Chapter 7, p. 173: You may add @safe: to the top

Re: @safe, pure and nothrow at the beginning of a module

2014-08-16 Thread Philippe Sigaud via Digitalmars-d-learn
On Sat, Aug 16, 2014 at 1:30 PM, Artur Skawina via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On 08/16/14 13:18, Philippe Sigaud via Digitalmars-d-learn wrote: We indeed need to put annotations inside aggregates to affect their innards. If that's true, I have a lot

Re: @safe, pure and nothrow at the beginning of a module

2014-08-16 Thread Philippe Sigaud via Digitalmars-d-learn
Artur: @safe, @trusted, @system, shared, immutable, const, inout and `extern (...)` affect child scopes. `synchronized` does too, but in a rather unintuitive way; hopefully nobody uses this. ;) Well, I also hope no one uses inout: at the module level? Other attributes, including 'pure' and

Re: Automatic Inference for Both Key and Value Types of an Associative Array

2014-08-15 Thread Philippe Sigaud via Digitalmars-d
Kenji Hara: I implemented partial type deduction in AA keys. https://github.com/D-Programming-Language/dmd/pull/3615 For example: auto[auto[$]] aa5 = [[1,2]:1, [3,4]:2]; static assert(is(typeof(aa5) == int[int[2]])); int[int[][$]] aa15 = [[[1],[2]]:1, [[3],[4]]:2]; static

Re: How to declare a parameterized recursive data structure?

2014-08-15 Thread Philippe Sigaud via Digitalmars-d
On Fri, Aug 15, 2014 at 9:13 PM, artemav via Digitalmars-d digitalmars-d@puremagic.com wrote: :) Wow, thanks for all replies. I realized too late that should write that's it. Hmm, It's also a good sign that D community is active. Can I add something? ;) You can also use a class, as they are

Re: Appender is ... slow

2014-08-15 Thread Philippe Sigaud via Digitalmars-d-learn
Quick test... Ah, thanks a lot Jonathan. I kept telling me I should probably test it on a simple case. OK, the good news is, Appender works in these cases (I mean, that's good news for Phobos). Now, I just have to find out why it's slower in my case :) import std.array;

Re: Appender is ... slow

2014-08-15 Thread Philippe Sigaud via Digitalmars-d-learn
I wonder if using plain `Array` instead may be result in better performance where immutability is not needed. Hmm, no: module appendertest; import std.array; import std.datetime; import std.stdio; import std.container; enum size = 1_000; void test1() { auto arr = appender!(int[])();

Re: Appender is ... slow

2014-08-15 Thread Philippe Sigaud via Digitalmars-d-learn
On Thu, Aug 14, 2014 at 11:33 PM, Joseph Rushton Wakeling via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On 14/08/14 19:16, Philippe Sigaud via Digitalmars-d-learn wrote: Do people here get good results from Appender? And if yes, how are you using it? An example where

Re: Appender is ... slow

2014-08-15 Thread Philippe Sigaud via Digitalmars-d-learn
It is very different with better compiler though : $ ldmd2 -release -O a.d $ ./appendertest Appender.put :378 ms, 794 μs, and 9 hnsecs Appender ~=:378 ms, 416 μs, and 3 hnsecs Std array :2 secs, 222 ms, 256 μs, and 2 hnsecs Std array.reserve :2 secs, 199 ms, 64 μs,

Re: Appender is ... slow

2014-08-15 Thread Philippe Sigaud via Digitalmars-d-learn
On Fri, Aug 15, 2014 at 1:57 PM, Messenger via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: T[size] beats all of those on dmd head, though it is inarguably a bit limiting. I confirm (even with 2.065). With ldc2 it's optimized out of the way, so it gives 0 hnsecs :-) Hmm, what

Re: Appender is ... slow

2014-08-15 Thread Philippe Sigaud via Digitalmars-d-learn
Well, I created a wrapper around a std.array.uninitializedArray call, to manage the interface I need (queue behavior: pushing at the end, popping at the beginning). When hitting the end of the current array, it either reuse the current buffer or create a new one, depending of the remaining

@safe, pure and nothrow at the beginning of a module

2014-08-15 Thread Philippe Sigaud via Digitalmars-d-learn
So I'm trying to use @safe, pure and nothrow. If I understand correctly Adam Ruppe's Cookbook, by putting @safe: pure: nothrow: at the beginning of a module, I distribute it on all definitions, right? Even methods, inner classes, and so on? Because I did just that on half a dozen of modules

Re: Appender is ... slow

2014-08-15 Thread Philippe Sigaud via Digitalmars-d-learn
On Friday, 15 August 2014 at 16:48:10 UTC, monarch_dodra wrote: On Friday, 15 August 2014 at 14:40:36 UTC, Philippe Sigaud wrote: Well, I created a wrapper around a std.array.uninitializedArray call, to manage the interface I need Make sure you don't use that if your type has elaborate

Re: @safe, pure and nothrow at the beginning of a module

2014-08-15 Thread Philippe Sigaud via Digitalmars-d-learn
In another module I marked as '@safe:' at the top, the compiler told me that a class opEquals could not be @safe (because Object.opEquals is @system). So it seems that indeed a module-level '@safe:' affects everything, since a class method was found lacking. (I put a @trusted attribute on it).

Re: Appender is ... slow

2014-08-15 Thread Philippe Sigaud via Digitalmars-d-learn
On Fri, Aug 15, 2014 at 10:04 PM, John Colvin via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: compiler, version, OS, architecture, flags? Compiler: DMD 2.065 and LDC 0.14 OS: Linux 64bits (8 cores, but there is no parallelism here) flags: -O -release -inline (and -noboundscheck

Re: Appender is ... slow

2014-08-14 Thread Philippe Sigaud via Digitalmars-d-learn
I don't know much about Phobos appender implementation details but the key thing with reusable buffer is avoid freeing them. AFAIR Appender.clear frees the allocated memory but `Appender.length = 0` does not, making it possible to just overwrite stuff again and again. I call .clear() only at

Re: Appender is ... slow

2014-08-14 Thread Philippe Sigaud via Digitalmars-d-learn
I've never really tried to benchmark it, but it was my understanding that the idea behind Appender was to use it to create the array when you do that via a lot of appending, and then you use it as a normal array and stop using Appender. That's how I use it, yes. It sounds like you're trying

Re: Appender is ... slow

2014-08-14 Thread Philippe Sigaud via Digitalmars-d-learn
There is a misunderstanding there: I'm using clear only to flush the state at the beginning of the computation. The Appender is a class field, used by the class methods to calculate. If I do not clear it at the beginning of the methods, I keep appending new results to old computations, which

Re: Appender is ... slow

2014-08-14 Thread Philippe Sigaud via Digitalmars-d-learn
Thanks! Repeating what I have mentioned during DConf talk - have you ever considered proposing Pegged for Phobos inclusion? It feels like important bit of infrastructure to me. At the time, it was considered (rightfully) far too slow and memory-hogging. I think having a generic lexer and a

Re: Are Delimited strings and HereDoc strings just here to suck ?

2014-08-11 Thread Philippe Sigaud via Digitalmars-d-learn
On Mon, Aug 11, 2014 at 10:09 PM, H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Mon, Aug 11, 2014 at 07:47:44PM +, Klaus via Digitalmars-d-learn wrote: I mean when writing a D lexer, you necessarly reach the moment when you think: Oh no! is this feature

Re: Are Delimited strings and HereDoc strings just here to suck ?

2014-08-11 Thread Philippe Sigaud via Digitalmars-d-learn
On Mon, Aug 11, 2014 at 10:58 PM, H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: In Flex, one way you can implement heredocs is to have a separate mode where the lexer is scanning for the ending string. So basically you have a sub-lexer that treats the heredoc as

DConf 2014 talks slides

2014-08-10 Thread Philippe Sigaud via Digitalmars-d
I'm catching up on some Dconf 2014 videos (great job, guys!) and wondering whether the associated slides will be put on the website somewhere. There are some where I'd like to ponder the code and ideas. It's not easy to do that on a stopped Youtube stream :) I know some links have been

Re: How to easily construct objects with multi-param constructors from lazy ranges?

2014-08-06 Thread Philippe Sigaud via Digitalmars-d-learn
Yea, but that won't work for forward ranges. It only provides opIndex if the underlying range provides it. Since the chunk size is a runtime parameter it can't implement opIndex efficiently for non-random access ranges. But in your case, your range is random-access, no? Or else, you can

Re: Help with porting grammar from PEGjs to D for dustjs project!

2014-08-06 Thread Philippe Sigaud via Digitalmars-d-learn
On Wed, Aug 6, 2014 at 9:09 AM, Uranuz via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: What I was thinking about is possibility to change ParseTree struct with user-defined version of it. And I was thinking about setting tree type as template parameter to grammar:

Re: Inner struct accessing host member

2014-08-06 Thread Philippe Sigaud via Digitalmars-d-learn
hmmm static and private... other keywords to try, but offhand it's been a while i don't know if either would change the behavior. Could just be inner scope limitations. Might be other tags/modifiers... I feel helpless :( No need to ;-) Thanks for your help, don't sweat it too much. I'm

Re: Help with porting grammar from PEGjs to D for dustjs project!

2014-08-05 Thread Philippe Sigaud via Digitalmars-d-learn
Is there multiline comments available inside PEGGED template? As far as I understand inline comments are set via # sign. No, no multiline comment. That's based on the original PEG grammar, which allows only #-comments.

Re: How to easily construct objects with multi-param constructors from lazy ranges?

2014-08-05 Thread Philippe Sigaud via Digitalmars-d-learn
Some range which takes an at compile time known number of elements from an input range and provides opIndex seems perfect to me, but as far as I know there's no such thing in Phobos. There is chunks: http://dlang.org/phobos/std_range.html#chunks

Re: static array in templated struct/class

2014-08-05 Thread Philippe Sigaud via Digitalmars-d-learn
http://pastebin.com/34sbffSa Your problem comes from lengthSquared: public auto lengthSquared = function () = val.reduce!((a,b) = a + b*b); That's an unusual way to define a method. Any reason why you are using a pointer to a function as a member? Do you need to be able to redefine it at

Inner struct accessing host member

2014-08-05 Thread Philippe Sigaud via Digitalmars-d-learn
I'd have thought that this would work: struct A { int[] i; B b; struct B { void foo() { i ~= 1;} } } void main() { A a; a.b.foo(); } But the compiler tells me 'need this for i of type int[]'. Is there any way I can gain access on i inside B?

Re: Inner struct accessing host member

2014-08-05 Thread Philippe Sigaud via Digitalmars-d-learn
On Tue, Aug 5, 2014 at 11:37 PM, Martijn Pot via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Does this help : http://www.digitalmars.com/d/archives/digitalmars/D/learn/Nested_struct_member_has_no_access_to_the_enclosing_class_data_38294.html Yes, that helps: that explains why

Re: Inner struct accessing host member

2014-08-05 Thread Philippe Sigaud via Digitalmars-d-learn
why it does not wor :). why it does not *work*, of course. Sigh.

Re: Inner struct accessing host member

2014-08-05 Thread Philippe Sigaud via Digitalmars-d-learn
On Tuesday, 5 August 2014 at 22:14:23 UTC, abanstadya wrote: programming Q, either youra newb or not, should rather be posted to 'http://forum.dlang.org/group/digitalmars.D.learn'. Your post appears on 'http://forum.dlang.org/group/digitalmars.D' which is more related to the lang. design

Re: Inner struct accessing host member

2014-08-05 Thread Philippe Sigaud via Digitalmars-d-learn
On Tuesday, 5 August 2014 at 23:47:00 UTC, Artur Skawina via Digitalmars-d-learn wrote: Is there any way I can gain access on i inside B? Not directly, but as you ask for /any/ way -- yes: struct B { void foo() { outer.i ~= 1; } ref A outer() inout @property { return

Re: Inner struct accessing host member

2014-08-05 Thread Philippe Sigaud via Digitalmars-d-learn
Era: broken_b.foo(); //i_a is accessible invisibly because overridden or transformed assuming it would be converted or copied/moved as appropriate. return b; //if a is a local variable then b becomes invalid even though it's a struct. return i_b; //same as return b return broken_b;

Re: Threadpools, difference between DMD and LDC

2014-08-04 Thread Philippe Sigaud via Digitalmars-d-learn
Without going into much detail: Threads are heavy, and creating a thread is an expensive operation (which is partially why virtually every standard library includes a ThreadPool). I haven't looked into detail your code, but consider using the TaskPool if you just want to schedule some tasks

Re: Threadpools, difference between DMD and LDC

2014-08-04 Thread Philippe Sigaud via Digitalmars-d-learn
On Mon, Aug 4, 2014 at 2:13 PM, Chris Cain via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: OK, I get it. Just to be sure, there is no ThreadPool in Phobos or in core, right? There is. It's called taskPool, though: http://dlang.org/phobos/std_parallelism.html#.taskPool Ah,

Re: Threadpools, difference between DMD and LDC

2014-08-04 Thread Philippe Sigaud via Digitalmars-d-learn
On Mon, Aug 4, 2014 at 3:36 PM, Dicebot via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Most likely those threads either do nothing or are short living so you don't get actually 10 000 threads running simultaneously. In general you should expect your operating system to start

Re: Threadpools, difference between DMD and LDC

2014-08-04 Thread Philippe Sigaud via Digitalmars-d-learn
On Mon, Aug 4, 2014 at 6:21 PM, Dicebot via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: vibe.d additions may help here: http://vibed.org/api/vibe.core.core/runTask http://vibed.org/api/vibe.core.core/runWorkerTask http://vibed.org/api/vibe.core.core/workerThreadCount task

Re: Threadpools, difference between DMD and LDC

2014-08-04 Thread Philippe Sigaud via Digitalmars-d-learn
On Mon, Aug 4, 2014 at 6:38 PM, Russel Winder via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Are these std.concurrent threads or std.parallelism tasks? A std.parallelism task is not a thread. Like Erlang or Java Fork/Join framework, the program specifies units of work and

Re: Threadpools, difference between DMD and LDC

2014-08-04 Thread Philippe Sigaud via Digitalmars-d-learn
https://github.com/D-Programming-Language/phobos/pull/1910 Very interesting discussion, thanks. I'm impressed by the amount of work you guys do on github.

Threadpools, difference between DMD and LDC

2014-08-03 Thread Philippe Sigaud via Digitalmars-d-learn
I'm trying to grok message passing. That's my very first foray into this, so I'm probably making every mistake in the book :-) I wrote a small threadpool test, it's there: http://dpaste.dzfl.pl/3d3a65a00425 I'm playing with the number of threads and the number of tasks, and getting a feel

Threadpools, difference between DMD and LDC

2014-08-03 Thread Philippe Sigaud via Digitalmars-d-learn
I'm trying to grok message passing. That's my very first foray into this, so I'm probably making every mistake in the book :-) I wrote a small threadpool test, it's there: http://dpaste.dzfl.pl/3d3a65a00425 I'm playing with the number of threads and the number of tasks, and getting a feel

Re: Help with porting grammar from PEGjs to D for dustjs project!

2014-08-03 Thread Philippe Sigaud via Digitalmars-d-learn
Uranuz: http://akdubya.github.io/dustjs/ So I need some help with rewriting grammar from PEGjs into PEGGED. Is this the grammar? https://github.com/akdubya/dustjs/blob/master/src/dust.pegjs If so, then I think I can provide some help. But I don't get what output you want (see below). Also

Re: Threadpools, difference between DMD and LDC

2014-08-03 Thread Philippe Sigaud via Digitalmars-d-learn
This is correct – the LLVM optimizer indeed gets rid of the loop completely. OK,that's clever. But I get this even when put a writeln(some msg) inside the task. I thought a write couldn't be optimized away that way and that it's a slow operation? Anyway, I discovered Thread.wait() in core in

Re: Help with porting grammar from PEGjs to D for dustjs project!

2014-08-03 Thread Philippe Sigaud via Digitalmars-d-learn
On Mon, Aug 4, 2014 at 7:13 AM, Uranuz via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I am real noob about grammar description languages so I need some explanation about it. As far as I understand expressions in curly bracers are used to modify syntax tree just in process of

Re: Type deduction on templated constructor.

2014-07-30 Thread Philippe Sigaud via Digitalmars-d-learn
I expected such an answer and I do understand the decisions behind it. Yet, you gave me a really GOOD news! Having to write cast(ubyte) 1 was way too much verbose for my liking, while the new ubyte(1) is reasonable enough. Why not use `1u`?

Re: Type deduction on templated constructor.

2014-07-30 Thread Philippe Sigaud via Digitalmars-d-learn
On Wed, Jul 30, 2014 at 11:46 AM, Philippe Sigaud philippe.sig...@gmail.com wrote: I expected such an answer and I do understand the decisions behind it. Yet, you gave me a really GOOD news! Having to write cast(ubyte) 1 was way too much verbose for my liking, while the new ubyte(1) is

Re: Compile time regex matching

2014-07-15 Thread Philippe Sigaud via Digitalmars-d-learn
I did, and I got it to work. Unfortunately, the code used to in the CTFE is left in the final executable even though it is not used at runtime. So now the question is, is there away to get rid of the excess baggage? Not that I know of. Once code is injected, it's compiled into the executable.

Re: new properties for basic types

2014-07-14 Thread Philippe Sigaud via Digitalmars-d-learn
Halas, that's not what the OP wants. He needs properties on the *type* itself: int.foo instead of foo!int. So no, this is not possible.

Re: Compile time regex matching

2014-07-14 Thread Philippe Sigaud via Digitalmars-d-learn
I am trying to write some code that uses and matches to regular expressions at compile time, but the compiler won't let me because matchFirst and matchAll make use of malloc(). Is there an alternative that I can use that can be run at compile time? You can try Pegged, a parser generator that

Re: Compile time regex matching

2014-07-14 Thread Philippe Sigaud via Digitalmars-d-learn
On Mon, Jul 14, 2014 at 3:19 PM, Artur Skawina via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On 07/14/14 13:42, Philippe Sigaud via Digitalmars-d-learn wrote: asserts get an entire copy of the parse tree. It's a bit wasteful, but using 'immutable' directly does not work here

Re: new properties for basic types

2014-07-14 Thread Philippe Sigaud via Digitalmars-d-learn
Hmm. So how do I use stuff like this: template defaultInit(T) { static if (!is(typeof({ T v = void; })))// inout(U) @property T defaultInit(T v = T.init); else @property T defaultInit(); } (this is from std.traits - ok, it's

Re: Opinions: The Best and Worst of D (for a lecture/talk I intend to give)

2014-07-08 Thread Philippe Sigaud via Digitalmars-d-learn
On Tue, Jul 8, 2014 at 7:50 AM, H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote quite a wall of text Wow, what to add to that? Maybe you scared other from participating ;-) * I'll second metaprogramming: the alliance between templates, CTFE and mixins is really nice.

Re: dependency graph

2014-07-06 Thread Philippe Sigaud via Digitalmars-d-learn
If you compile your project with the -deps flag, the compiler will output import dependencies. With -deps=filename, the output will go into filename. From there, you'll have to parse and create the graph, though. Maybe have a look into rdmd source, to see how the dependency extraction is done

Re: What exactly module in D means?

2014-07-06 Thread Philippe Sigaud via Digitalmars-d-learn
On Sat, Jul 5, 2014 at 6:35 PM, Andre Tampubolon via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I've been reading the newsgroup for a while, and it seems that one of the reason folks like D is because it supports module. My question is: what does module mean? A quick google

Re: How to test templates for equality?

2014-07-06 Thread Philippe Sigaud via Digitalmars-d-learn
Seeing his example, the OP wants a solution that works even for templates: template Test1(T) {} pragma(msg, instanceArgsOf!(Test1, Test1!int)); which fails because Test1!int is not a type (std.traits.isInstanceOf fails also, for the same reason). And is(symbol == Name!Args, Args...) does not

Re: Trying to reproduce Node.js async waterfall pattern.. (Meta-programming)

2014-06-24 Thread Philippe Sigaud via Digitalmars-d-learn
Yes, the final callback is always called, but if an error is passed to the callback by any of the main steps in the sequence ladder, it will immediately jump to the final callback and not execute further steps. OK. What do you mean? The compiler does deduce the type of Funcs. If you look

Re: Trying to reproduce Node.js async waterfall pattern.. (Meta-programming)

2014-06-23 Thread Philippe Sigaud via Digitalmars-d-learn
On Mon, Jun 23, 2014 at 9:39 PM, Christian Beaumont via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Each function is given a callback, that when called, steps the waterfall forward on to the next function to process. If an error is passed to the callback (instead of null),

Re: What is the correct way to forward method calls to the struct field?

2014-06-22 Thread Philippe Sigaud via Digitalmars-d-learn
On Sun, Jun 22, 2014 at 5:04 PM, monnoroch via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: There is also a problem: when i declare opDispatch to be private, i still have access to this forwarding from another package. Is it a bug or what? I don't know. I never used private in

Re: What is the correct way to forward method calls to the struct field?

2014-06-22 Thread Philippe Sigaud via Digitalmars-d-learn
On Sun, Jun 22, 2014 at 5:02 PM, monnoroch via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Thanks a lot! There is a problem though: when i pass incorrect parameters to such a method, it says, that S has no such field, which is a misleading error message. You can test the

Re: template mixins for boilerplate

2014-06-21 Thread Philippe Sigaud via Digitalmars-d-learn
Out of curiosity, why use a mixin template containing a string mixin instead of, well, directly injecting a string mixin in your struct, with a function?

Re: template mixins for boilerplate

2014-06-21 Thread Philippe Sigaud via Digitalmars-d-learn
On Sat, Jun 21, 2014 at 4:24 PM, Dicebot via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Saturday, 21 June 2014 at 13:45:14 UTC, Philippe Sigaud via Digitalmars-d-learn wrote: Out of curiosity, why use a mixin template containing a string mixin instead of, well, directly

  1   2   >