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

2014-06-21 Thread Philippe Sigaud via Digitalmars-d-learn
You can use 'auto' to let the compiler deduce the return type. Here I use 'foo' which returns an int and 'bar', which returns void. struct SomeT { int foo(double d) { return 0;} void bar(double d) { return;} } struct S { auto /* here */ opDispatch(string name, Args...)(Args

Re: template mixins for boilerplate

2014-06-20 Thread Philippe Sigaud via Digitalmars-d-learn
Use a string mixin? string fun(string name) { return public static int ~ name ~ () { return 0; }; } struct S { mixin (fun(fctn1)); } void main() { S s; import std.stdio; writeln(s.fctn1()); }

Re: Universal Construction Syntax for Pointers?

2014-06-14 Thread Philippe Sigaud via Digitalmars-d-learn
Would auto i = (int*)(3); make sense? Does it work?

Re: Universal Construction Syntax for Pointers?

2014-06-14 Thread Philippe Sigaud via Digitalmars-d-learn
And I don't think it should, because the heap allocation that you're probably expecting should be explicit IMO. For me it's also unintuitive, because I would read it as constructing a pointer that points to the address 3. I agree. I'm trying to get a feel on the limits of this new

Re: does there exist a dimensional analysis library for D?

2014-06-13 Thread Philippe Sigaud via Digitalmars-d-learn
Hi Vlad, you can try David Nadlinger's std.units: http://klickverbot.at/code/units/std_units.html See the discussion at http://forum.dlang.org/thread/io1vgo$1fnc$1...@digitalmars.com From what I deemly remember of Boost/units, it's a bit less complete, but far easier to use.

Re: Pushing D's mixin to the limits: Project Euler Problem 61 from Ruby to D by David Oftedal

2014-06-12 Thread Philippe Sigaud via Digitalmars-d-announce
Drat, I need a livejournal account to post comments? Well, I can at least create a reddit account, I guess... In the Ruby version, I was able to add the methods directly to the Integer class, using what's known as monkey patching, allowing me to make calls like3.pentagonal. In D, the methods are

Re: Pushing D's mixin to the limits: Project Euler Problem 61 from Ruby to D by David Oftedal

2014-06-12 Thread Philippe Sigaud via Digitalmars-d-announce
On Thu, Jun 12, 2014 at 10:35 PM, Rounin via Digitalmars-d-announce digitalmars-d-announce@puremagic.com wrote: Hey there! Oh cool, thanks for answering! Yeah, to expect people to register on LiveJournal in this age of Facebook... Sorry about that; It must have been to deter the spammers.

Re: one of the weirdest bugs ever - request for testing

2014-06-12 Thread Philippe Sigaud via Digitalmars-d-learn
// wrong code gen(*) with -release -O -inline -noboundscheck or // with -release -inline -noboundscheck but only if std.file is imported: auto x = countUntil( names, FOO ); write(x); if( 0 = x ) writeln( found a FOO); // (*) not found! } I'm running OSX Mavericks with

Re: For Chuck Allison: possible homework in D

2014-06-09 Thread Philippe Sigaud via Digitalmars-d
struct / class Element(T) { T name; T[T] attributes; // ... string toString() { return ...; } } Why did you chose the same type for keys and values? And shouldn't 'name' always be a string?

Re: For Chuck Allison: possible homework in D

2014-06-09 Thread Philippe Sigaud via Digitalmars-d
I see, thanks.

Re: For Chuck Allison: possible homework in D

2014-06-08 Thread Philippe Sigaud via Digitalmars-d
Yes indeed, you can provide a range interface on a tree. That's a good idea! But I suppose Chuck wants to teach his students generic notions such as mapping or folding. Ranges are more a D-specific thing. Also, what's interesting is that when mapping a tree, you can keep its 'shape', whereas

For Chuck Allison: possible homework in D

2014-06-07 Thread Philippe Sigaud via Digitalmars-d
I was watching Chuck Allison talk yesterday, and wondered what could be a possible homework in D. Maybe other people here have some ideas, maybe Bearophile will point to RosettaCode, I don't know. But here is a possible idea: Trees. Since you taught them about ranges/lists and functional

Re: For Chuck Allison: possible homework in D

2014-06-07 Thread Philippe Sigaud via Digitalmars-d
On Sat, Jun 7, 2014 at 5:00 PM, MattCoder via Digitalmars-d digitalmars-d@puremagic.com wrote: Yes this is interesting idead. -But If I remember well, he said to send him an e-mail with ideas. So I think you should point him (through e-mail) about this topic! I will. I just wanted to see what

Re: Creating new types from tuples.

2014-06-07 Thread Philippe Sigaud via Digitalmars-d-learn
Is there any reason you couldn't (or would rather not) use structs rather than tuples? That would work. What would be the best way to auto-generate the types? I have somewhere around 30 already, and the number will grow with this project. Evan Davis Maybe you could use a struct template,

Re: Optionally strongly typed array indexes

2014-06-06 Thread Philippe Sigaud via Digitalmars-d
Also true, though as a side note, I think a library solution for this could be quite nice: enum newton = 1.as!kg*m/s^2; // One possibility. enum newton = 1*kg*m/square(s); // Another. Sorry to intrude, but you can also get: enum newton = 1.kg/m/s^^2; Which is quite readable. In this

Re: DConf 2014 Day 1 Talk 2

2014-06-05 Thread Philippe Sigaud via Digitalmars-d-announce
On Tue, Jun 3, 2014 at 10:54 PM, Jonathan Crapuchettes Here is a link to the slides from the presentation. http://slides.com/jonathancrapuchettes/dconf On the 'issues with D' slide, you cite 'Can't get member names from Tuples'. Do you mean: alias Entry = Tuple!(int, index, string, value);

Re: When is a slice not a slice?

2014-06-05 Thread Philippe Sigaud via Digitalmars-d-learn
enum b = DataAndView(1); assert (!sameTail(b.data, b.view)); I suppose it's because enums are manifest constants: the value they represent is 'copy-pasted' anew everywhere it appears in the code. So for arrays and associative arrays, it means recreating a new value each and

Re: DConf 2014 Day 1 Talk 2

2014-06-03 Thread Philippe Sigaud via Digitalmars-d-announce
On Tue, Jun 3, 2014 at 10:54 PM, Jonathan Crapuchettes via Digitalmars-d-announce digitalmars-d-announce@puremagic.com wrote: Here is a link to the slides from the presentation. http://slides.com/jonathancrapuchettes/dconf Very nice talk! And quite an interesting piece of software you built

Re: Casting Structs

2014-06-01 Thread Philippe Sigaud via Digitalmars-d
At the very least, it's contradicted by the website: http://dlang.org/expression#CastExpression Casting a value v to a struct S, when value is not a struct of the same type, is equivalent to: S(v) In your case, you have no 'this' in Decimal to accept a Decimal with other arguments. This should

Re: enums

2014-06-01 Thread Philippe Sigaud via Digitalmars-d-learn
On Sat, May 31, 2014 at 10:14 PM, bearophile via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: In contrast to those two examples where immutable can be used at compile time, what are some other cases where it is necessary to use enum instead of immutable? By default use enum

Re: how to detect ctfe

2014-06-01 Thread Philippe Sigaud via Digitalmars-d-learn
But let's keep in mind it's a *runtime* value. You cannot use it at compile-time as a boolean for a 'static if'. So: if (__ctfe) // yes { // compile-time path } else { // runtime path } But not: static if (__ctfe) // no { // compile-time path, including new global declarations }

Re: Casting Structs

2014-06-01 Thread Philippe Sigaud via Digitalmars-d-learn
On Sun, Jun 1, 2014 at 12:34 AM, Timon Gehr via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: This behaviour is independent of templates. Struct values of the same size can be reinterpret-cast to each other this way even if their types are completely unrelated. Do you know if

Re: DMD fail when using both reflection and UDA

2014-06-01 Thread Philippe Sigaud via Digitalmars-d-learn
In any case, it's an internal compiler error, so it's a bug. Users should never see ICEs. Could you please report it, with the entire error message?

Re: Hiding types

2014-05-31 Thread Philippe Sigaud via Digitalmars-d-learn
On Sat, May 31, 2014 at 6:39 AM, Dicebot via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: private in D does not provide any strong guarantees, it only controls direct access to the symbol. You effectively want some sort of strict internal linkage attribute which does not exist

Re: Hiding types

2014-05-31 Thread Philippe Sigaud via Digitalmars-d-learn
What do you mean? Like this? Hidden* foo() { return new Hidden();} Yes, this way you can control all aspects of the construction and use. You wouldn't need to make it private even, just don't lay out the struct in the normal import: struct Hidden; I think you would need to use a .di

Re: Forward reference to nested function not allowed?

2014-05-31 Thread Philippe Sigaud via Digitalmars-d-learn
See: http://dlang.org/function.html#variadicnested The second example explains that nested functions can be accessed only if the name is in scope.

Re: D Users Survey: Primary OS?

2014-05-30 Thread Philippe Sigaud via Digitalmars-d
Linux 64bits here also. In fact, contrary to the OP belief, it's mainly a Linux crowd here. People using Windows regularly complain about it, saying we don't see the way some tools are missing or not working as well on Windows.

Re: enums

2014-05-30 Thread Philippe Sigaud via Digitalmars-d-learn
In D enum can be used to define manifest constants. This means constants known at compile time. In practice for a double there isn't a lot of difference. In general you can't take the address of a manifest constant, unlike immutables. Because they do not exist as 'variables' or symbol in the

Re: enums

2014-05-30 Thread Philippe Sigaud via Digitalmars-d-learn
A good use of 'static immutable', sadly not voted into the language. :-) But you're right, and I remember being tripped by this.

Re: enums

2014-05-30 Thread Philippe Sigaud via Digitalmars-d-learn
On Fri, May 30, 2014 at 7:28 PM, Ali Çehreli digitalmars-d-learn@puremagic.com wrote: On 05/30/2014 08:30 AM, Russel Winder via Digitalmars-d-learn wrote: enum double p0 = 0.0045; As others have already said, p0 is a manifest constant. Interestingly, it can be thought of like a C

Re: enums

2014-05-30 Thread Philippe Sigaud via Digitalmars-d-learn
On Fri, May 30, 2014 at 7:56 PM, Steven Schveighoffer wrote: You can as long as the value is known at compile time: http://dpaste.dzfl.pl/5a710bd80ab0 Oh wow. And that works for static if also: http://dpaste.dzfl.pl/f87321a47834 Man. That opens some new possibilities.

Hiding types

2014-05-30 Thread Philippe Sigaud via Digitalmars-d-learn
I'm trying to 'hide' a type, so as not to see it outside its module. I want to control the way it's created and used. I know of Voldemort types and '@disable this', but for now I'm just trying to use 'private'. Halas, it seems it can be circumvented: * module A; private struct

Re: Hiding types

2014-05-30 Thread Philippe Sigaud via Digitalmars-d-learn
On Friday, 30 May 2014 at 19:54:00 UTC, safety0ff wrote: On Friday, 30 May 2014 at 19:50:43 UTC, Philippe Sigaud wrote: Am I misunderstanding something or is that a bug? Try: auto foo() { return Hidden();} I'm not seeing any difference? I'm still able to create a value of type Hidden

Re: Hiding types

2014-05-30 Thread Philippe Sigaud via Digitalmars-d-learn
On Friday, 30 May 2014 at 20:02:40 UTC, Steven Schveighoffer wrote: If you want an opaque struct, you need to return it by pointer. What do you mean? Like this? Hidden* foo() { return new Hidden();} ? Otherwise, the user must be able to know what type it is (otherwise, how would he use

Re: Adam D. Ruppe's D Cookbook now available!

2014-05-29 Thread Philippe Sigaud via Digitalmars-d-announce
On Thu, May 29, 2014 at 12:28 PM, Chris via Digitalmars-d-announce digitalmars-d-announce@puremagic.com wrote: On Wednesday, 28 May 2014 at 18:14:28 UTC, Walter Bright wrote: http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book

Re: Adam D. Ruppe's D Cookbook now available!

2014-05-29 Thread Philippe Sigaud via Digitalmars-d-announce
On Thu, May 29, 2014 at 2:31 PM, Jacob Carlborg wrote: Amazon has a version for their Kindle [1]. I have not seen any mentioning of other formats. [1] http://www.amazon.com/D-Cookbook-Adam-D-Ruppe-ebook/dp/B00KLAJ62M/ref=sr_1_1_title_1_kin?s=booksie=UTF8qid=1401366690sr=1-1 But the paper

Re: Scott Meyers' DConf 2014 keynote The Last Thing D Needs

2014-05-27 Thread Philippe Sigaud via Digitalmars-d-announce
I did a translation of most of the code in the slides. http://dpaste.dzfl.pl/72b5cfcb72e4 I'm planning to transform it into blog post (or series). Right now it just has some scratch notes. Feel free to let me know everything I got wrong. That's a good idea. I think most of us did that while

Re: Thank you Kenji

2014-05-23 Thread Philippe Sigaud via Digitalmars-d
For those who don't know Kenji because he rarely posts on the forums, Brad put up a slide at Dconf yesterday showing the top committers by pull requests over the last three years and Kenji was at the top for '12 and '13. He was second so far this year, after Andrej. I don't know if he

Re: How to get struct's members ?

2014-05-23 Thread Philippe Sigaud via Digitalmars-d-learn
On Fri, May 23, 2014 at 8:44 AM, monarch_dodra via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Friday, 23 May 2014 at 01:17:18 UTC, bioinfornatics wrote: I would like to get struct's members and zip them with an action tupleof will do what you need (mostly). However, I

Re: Avoiding __traits(getAttributes, ...) on alias

2014-05-10 Thread Philippe Sigaud via Digitalmars-d-learn
Vlad Levenfeld: but beware I've noticed that sometimes this is not equivalent to the previous version and I'm not sure how or why that happens. In particular I notice that mixin(const bool value = ~expr~;)); and const bool value = mixin(expr); are not the same, for some reason. What

Re: Avoiding __traits(getAttributes, ...) on alias

2014-05-10 Thread Philippe Sigaud via Digitalmars-d-learn
else // doesn't compile, member is not accessible error foreach (type; __traits (getAttributes, mixin(`T.`~member))) static if (is (type == attribute)) return true; return false; Maybe its trying to use it inside of __traits that is causing it? Maybe __traits is

Re: __traits with alias

2014-05-08 Thread Philippe Sigaud via Digitalmars-d-learn
alias a = __traits(getMember, module_, m); // fails //Error: basic type expected, not __traits //Error: semicolon expected to close alias declaration Is this a bug or I've missed something? It's a syntax limitation for alias. That bites us from time to time. A

Re: Making enum join variadic

2014-05-02 Thread Philippe Sigaud via Digitalmars-d-learn
On Fri, May 2, 2014 at 12:59 PM, Nordlöw digitalmars-d-learn@puremagic.com wrote: Some final questions: - Is join a good naming for this? Is chain better? - Is it better to be verbose with joinEnums? I'd be verbose. It's an uncommon operation, bound to surprise a reader a bit.It's better to

Re: How to use the result of __traits( allMembers , T ) with string mixins ?

2014-04-28 Thread Philippe Sigaud via Digitalmars-d-learn
On Mon, Apr 28, 2014 at 5:45 PM, Andrej Mitrovic via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: If you need to store the tuple as an array to some variable, then you would use that syntax. It all depends on what you're trying to do from the call site. Ultimately it won't

Re: How to use the result of __traits( allMembers , T ) with string mixins ?

2014-04-28 Thread Philippe Sigaud via Digitalmars-d-learn
On Mon, Apr 28, 2014 at 8:20 PM, Dicebot via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: You can do the same iterating directly over allMembers list, why would you prefer array here? Hmm, indeed. One advantage would be to get a range, and thus the power and filtering, mapping

Re: Lazy mixins

2014-03-25 Thread Philippe Sigaud
That's probably not the solution you want, but could you use direct string mixins? import std.stdio; string B() { return `void foo(double d) { writeln(foo(double)); }`; } class C { void foo(int x) { writeln(x); } mixin(B()); } void main() { auto c = new C(); c.foo(1.3); }

Re: Lazy mixins

2014-03-25 Thread Philippe Sigaud
No, I think I mentioned that string mixins can't get the context they are inserted in. Why would I simply wrap a string mixin around a template mixin if there wasn't some purpose that string mixins couldn't use in the first place? OK. I just preferred to ask, to be sure. Hence you can't do

Re: Compile time only delegates

2014-03-25 Thread Philippe Sigaud
This works for me (2.064): import std.stdio : writeln; void main() { mixin({ return int x;; }()); writeln(x); }

Re: 1st draft of complete class-based std.random successor

2014-03-23 Thread Philippe Sigaud
On Sun, Mar 23, 2014 at 11:17 AM, bearophile bearophileh...@lycos.com wrote: Joseph Rushton Wakeling: int r = data[uniform![)(0, data.length)]; D also accepts: immutable r = data[uniform![)(0, $)]; Really? The '$' part works?

Re: ICE for x[] + x[]

2014-03-23 Thread Philippe Sigaud
On Sun, Mar 23, 2014 at 7:10 PM, Nordlöw per.nord...@gmail.com wrote: e2ir.c Probably this one: https://d.puremagic.com/issues/show_bug.cgi?id=12179

Re: Combining template parameters deduction with default template parameters

2014-03-23 Thread Philippe Sigaud
On Sun, Mar 23, 2014 at 12:23 PM, Uranuz neura...@gmail.com wrote: Yes. I like it more that ivoking one function from another. But this trick not working in DMD 2.063 as I understand. Is there any reason to still use 2.063 (honest question)? The current one is 2.065 with .066 in alpha state.

Re: Listing all functions in a module

2014-03-23 Thread Philippe Sigaud
On Sun, Mar 23, 2014 at 1:31 PM, Rikki Cattermole alphaglosi...@gmail.com wrote: Well I just made this for you, so here it is anyway: I wonder whether we could have a 'D recipes' page on the wiki, since some question appear regularly. Does one already exist?

Re: Check for presence of function

2014-03-23 Thread Philippe Sigaud
On Sun, Mar 23, 2014 at 1:40 PM, Steve Teale steve.te...@britseyeview.com wrote: What's the cool/idiomatic D way to test at compile time if a struct has a member function with a particular signature? Along the lines of: struct Unrelated { ... } template isSomething(T) { enum bool

Re: Check for presence of function

2014-03-23 Thread Philippe Sigaud
Ideally, the alias part of the grammar could be extended and isSomething simplified as: alias isSomething(T) = __traits(compiles, { Unrelated* up; T.init.doSomething(up); } ); But this is not accepted by the grammar right now, because of __traits()

Re: Listing all functions in a module

2014-03-23 Thread Philippe Sigaud
On Sun, Mar 23, 2014 at 1:52 PM, Rikki Cattermole alphaglosi...@gmail.com wrote: I wonder whether we could have a 'D recipes' page on the wiki, since some question appear regularly. Does one already exist? I don't know. Other than the Rosetta code stuff, I believe there is nothing [0].

Re: Listing all functions in a module

2014-03-23 Thread Philippe Sigaud
If your wanting to lead please do :) Well, I'm trying to understand how to add a new recipe, with the correct tag. There, here it is: http://wiki.dlang.org/Finding_all_Functions_in_a_Module Feel free to edit it!

Re: Check for presence of function

2014-03-23 Thread Philippe Sigaud
On Sun, Mar 23, 2014 at 2:50 PM, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: Pretty sure it's because you're using 'alias' instead of 'enum'. This works: Oww! For years, D told me I couldn't use __traits in an easy way like this. I'll have to teach me out of it, and use enum :-) Damn, but

Re: Article: Functional image processing in D

2014-03-22 Thread Philippe Sigaud
On Fri, Mar 21, 2014 at 12:04 PM, Vladimir Panteleev vladi...@thecybershadow.net wrote: http://blog.thecybershadow.net/2014/03/21/functional-image-processing-in-d/ Some highlights from a recent overhaul of the graphics package from my D library. It makes use of a number of D-specific language

Re: Article: Functional image processing in D

2014-03-22 Thread Philippe Sigaud
On Sat, Mar 22, 2014 at 4:10 PM, Graham Fawcett fawc...@uwindsor.ca wrote: I think this is it: https://github.com/CyberShadow/ae Hmm, there is the /demo directory, that can be useful. But I don't see any documentation per se.

Re: Template with template?

2014-03-20 Thread Philippe Sigaud
I thought the array T[] traits could hold any _type_ the template Trait is instantiated into. Different instantiations of a template could become totally unrelated types (heck, even things that are *not* types: function definitions, values, code blocks, ...). So there is now way for an

Re: linear search using 'find' on an array of structs?

2014-03-09 Thread Philippe Sigaud
assert(!find!(toLower(a) == b)(s, hello).empty); assert(!find!(toLower(a) == b)(clist.name, name2).empty); But clist is an array of c's, it has no `.name` field by itself. So, put the `.name` call inside the comparator: assert( find!(toLower(a.name) == b)(clist

Re: My D book is now officially coming soon

2014-03-03 Thread Philippe Sigaud
On Mon, 03 Mar 2014 11:37:48 -0500, Adam D. Ruppe destructiona...@gmail.com wrote: As some of you might know, I've been working on a D book over the last few months. It is now available as coming soon on the publisher's website:

Re: Nobody understands templates?

2014-03-02 Thread Philippe Sigaud
https://semitwist.com/articles/article/view/template-primer-in-d http://nomad.so/2013/07/templates-in-d-explained/ http://ddili.org/ders/d.en/templates.html That's a nice list. Is there a place on the wiki where these could be linked to?

Re: What does q{...} mean?

2014-02-24 Thread Philippe Sigaud
On Monday, 24 February 2014 at 11:41:41 UTC, Gary Willoughby wrote: I keep seeing this syntax used a bit and i'm stumped to what it means. What is it? enum foo = q{ // ??? }; It's a token string though, not a delimited string. See the section Token Strings on that page. For Gary: the

Re: Open Source Report Card

2014-02-23 Thread Philippe Sigaud
And I realized I meant symmetrical. IIRC reflexive means you're your own friend. That would be a very sad message from osrc: the coder you're the most close is... yourself. Go hide under a rock! http://osrc.dfm.io/MartinNowak Martin's developer personality is very similar to Martin

Re: Open Source Report Card

2014-02-22 Thread Philippe Sigaud
And it creates new compliments every time you refresh. Mirror mirror on the wall.. LOL! Simply genious :) I'm going to refresh until I have all of them, and I'll print them on my CV. The internet says so, so it must be true! The Internet says I'm an exceptional coder *and* a social guy

Re: Open Source Report Card

2014-02-22 Thread Philippe Sigaud
Le 22 févr. 2014 16:10, Jacob Carlborg d...@me.com a écrit : On 2014-02-22 04:07, Orvid King wrote: Apparently I am a C# coder (have been for the last 3 years, only came into real D dev within the last year or so), and yet It seems like Orvid is—or should be—friends with jacob-carlborg.

Re: Open Source Report Card

2014-02-22 Thread Philippe Sigaud
Friendship is neither reflexive, nor transitive :-) Not even friendship in D :) And I realized I meant symmetrical. IIRC reflexive means you're your own friend. That would be a very sad message from osrc: the coder you're the most close is... yourself. Go hide under a rock! Anyway... That's

Re: Range Construction Pattern

2014-02-22 Thread Philippe Sigaud
Now what remains is to retstrict create to only take a fun with *no* input arguments and a non-void return. How do I do that? With a template contraint. Not tested: import std.traits: isCallable, ParameterTypeTuple, ReturnType; auto create(alias fun)(size_t n) if (isCallable!fun

Re: Range Construction Pattern

2014-02-22 Thread Philippe Sigaud
You can check if arbitrary code compiles with the if-typeof-delegate-trick: -- static if(is(typeof({ code} { // code compiles } -- Or with __traits(compiles, code), which better documents the intent.

Re: Range Construction Pattern

2014-02-22 Thread Philippe Sigaud
per.nordlow: My try so far: import std.traits: isCallable, ReturnType, arity, ParameterTypeTuple; enum arityMin0(alias fun) = __traits(compiles, fun()); // new syntax in 2.064 auto repeat(alias fun)(size_t n) if (isCallable!fun arityMin0!fun

Re: Lumen will be a part of the KDE 4.13 Release

2014-02-21 Thread Philippe Sigaud
On Thursday, 20 February 2014 at 14:16:51 UTC, David wrote: Lumen, the DCD plugin for Kate/KDevelop will be included in the KDE 4.13 release: http://kate-editor.org/2014/02/20/lumen-a-code-completion-plugin-for-the-d-programming-language/ Oh boy oh boy. I'm using Kate daily to code in D (I

Re: Is there kind of associative tuple - like syntax in D?

2014-02-21 Thread Philippe Sigaud
Justin: alias MyFoo = Foo!(opt1(23), opt2(foo)); That's also my preferred solution. I find it easy to read and it's quite typesafe (also, it allows for more complex possibilities like n-params options). Another solution could be to use an associative array literal for each option (you have to

Re: Recent improvements

2014-02-19 Thread Philippe Sigaud
On Wed, Feb 19, 2014 at 1:29 PM, Bienlein jeti...@web.de wrote: There is the nice old Smalltalk-80 inject:into: method in the Collection class: A little more general ;-). The Scala guys have also cloned it where it is called foldLeft. Oh, but D has `reduce`, for years now. It was maybe one

Re: Recent improvements

2014-02-19 Thread Philippe Sigaud
On Wed, Feb 19, 2014 at 2:18 PM, Bienlein jeti...@web.de wrote: I see. Unhappily, I don't have a D compiler handy. Would this compile: immutable s = [red, blue].sum If not, it would be interesting to understand how that works :-) It won't work, since binary + is not defined for strings. I

Re: Implementing Haskell's Type-Level Quicksort in D

2014-02-14 Thread Philippe Sigaud
On Fri, Feb 14, 2014 at 3:24 PM, bearophile bearophileh...@lycos.com wrote: Meta: While it is heavier than Haskell's syntax, I have been consistently and pleasantly surprised by how powerful D's template pattern matching is (bugs notwithstanding). I wonder how well-known this is outside this

Re: Implementing Haskell's Type-Level Quicksort in D

2014-02-13 Thread Philippe Sigaud
On Fri, Feb 14, 2014 at 3:54 AM, Meta jared...@gmail.com wrote: It seems strange that it would choke now, as Cons is a struct. Therefore, Cons!(Three, ...) should create a new type, and `L: Cons!(a, b), a, b` shouldn't be any trouble to destructure into two types, `Three` and `Cons!(Two,

Re: sin, cos, other languages and DMD/LDC difference

2014-02-09 Thread Philippe Sigaud
Floating point sucks like that. Looks like a mail signature :-)

Re: sin, cos, other languages and DMD/LDC difference

2014-02-09 Thread Philippe Sigaud
BTW, the differences in results is not due to optimization, but to dmd keeping intermediate results to 80 bits of precision, while other compilers are doing 64 bit precision on intermediate results. OK, well noted. It also seems many languages silently use the same C library to power their

sin, cos, other languages and DMD/LDC difference

2014-02-08 Thread Philippe Sigaud
I was reading this thread on the Clojure Google group: https://groups.google.com/forum/#!topic/clojure/kFNxGrRPf2k Where the guy is mostly computing (converting from the C++ code): import std.math; import std.stdio; double g(double x) { return sin(2.3*x) + cos(3.7*x); } void main() {

Re: sin, cos, other languages and DMD/LDC difference

2014-02-08 Thread Philippe Sigaud
LDC2 optimizes this code even worse than DMD. I naively thought that optimizations did not change computation results. I guess it's no different from C: same ocode, same computer, but different compiler = different results. Oh well...

Re: Undefined identifier error with enum in the separate module

2014-02-02 Thread Philippe Sigaud
Bearophile: I have seen other people hit this problem (like problems caused by having a set.d module containing a Set struct plus a set helper function). Is this worth warning against (with a dmd warning/error)? I'd prefer an error, with the same kind of nice message you get when you forget

Re: Undefined identifier error with enum in the separate module

2014-02-02 Thread Philippe Sigaud
This is the ER I have opened, if you have comments or you don't agree with my ideas, please comment there: https://d.puremagic.com/issues/show_bug.cgi?id=12059 Well, I really thought it was forbidden (as in: the code will never work). I guess you can define foo inside module foo.d and use it

Re: Undefined identifier error with enum in the separate module

2014-02-01 Thread Philippe Sigaud
// Reply.d import CodeEnum; unittest { auto.e = CodeEnum.OK; // Error: undefined identifier 'OK' } What I am doing wrong? The module and your enum have the same name. When the compiler sees the `CodeEnum` symbol, it considers you're referring to the module. This module does not

Re: Profiling

2014-01-25 Thread Philippe Sigaud
On Fri, Jan 24, 2014 at 10:25 PM, Benjamin Thaut c...@benjamin-thaut.de wrote: What Plattform are you profiling on? Linux 32bits. Does it change something? I'm not using any OS-specific part of Phobos, AFAICT.

Profiling

2014-01-24 Thread Philippe Sigaud
I'm trying to use the `-profile` flag for DMD and, without any documentation, I can't really understand the resulting log files: * They contain only mangled names. Is there a way to get demangled, human-readable symbols? * Can someone tell me what the numbers means? Is there a page

Re: Profiling

2014-01-24 Thread Philippe Sigaud
On Fri, Jan 24, 2014 at 8:35 PM, Brad Roberts bra...@puremagic.com wrote: Please file a bug on this. The docs should be on dlang.org. Here it is: https://d.puremagic.com/issues/show_bug.cgi?id=11985

Re: Array of pointers

2014-01-20 Thread Philippe Sigaud
On Mon, Jan 20, 2014 at 10:58 AM, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: On 1/16/14, Philippe Sigaud philippe.sig...@gmail.com wrote: The thing is, an array is a reference type Actually it's not, let's not confuse people with the terminology here. To recap for people new to arrays

Re: Array of pointers

2014-01-16 Thread Philippe Sigaud
On Thu, Jan 16, 2014 at 10:47 AM, Rene Zwanenburg renezwanenb...@gmail.com wrote: Keep in mind that, unlike in c++, D classes are reference types: class Node { Node[] nodes; // This is valid } Structs are value types though, so using a struct in the above example is illegal. That's

Re: Range-Based Graph Search in D (blog post)

2014-01-11 Thread Philippe Sigaud
Trying to write a bit more about D on my blog now. To start, I've written about a proof-of-concept range-based API for graph search. http://poita.org/2014/01/09/range-based-graph-search-in-d.html I'd greatly appreciate any feedback on the design. As we don't yet have a graph library for D,

Re: Create mixins from a list of strings

2014-01-11 Thread Philippe Sigaud
Maybe you could use just one name and put the dispatching code inside it? T actor(T)(T t) { switch (t.name) { case Gramm.Expr: return foo(t); case Gramm.FunctionCall: return foo(t); case Gramm.Declaration: return foo(t);

Re: Create mixins from a list of strings

2014-01-11 Thread Philippe Sigaud
On Sat, Jan 11, 2014 at 2:34 PM, Casper Færgemand\ shortt...@hotmail.com@puremagic.com wrote: On Saturday, 11 January 2014 at 09:17:34 UTC, Philippe Sigaud wrote: case Gramm.Expr: return foo(t); case Gramm.FunctionCall: return foo(t); case

Re: Create mixins from a list of strings

2014-01-11 Thread Philippe Sigaud
Note that closures are not (yet) supported in CTFE, because else another solution would be a function-returning function: auto bar(string s, int i) { return (ParseTree p) { p.name ~= s ~ to!string(i); return p; }; } Duh, instead of closures,

Re: Is it possible to handle 'magic' property assignments a'la PHP?

2014-01-07 Thread Philippe Sigaud
On Tue, Jan 7, 2014 at 8:50 AM, Jacob Carlborg d...@me.com wrote: I would like to have that in D as well, but with braces instead: void loop (void delegate () dg); loop { // endless loop } What about: void loop(void delegate() dg); loop({ ... }); Since any block is a void

Re: Is it possible to handle 'magic' property assignments a'la PHP?

2014-01-06 Thread Philippe Sigaud
I didn't know that, thanks. I read it during the holidays in Martin Fowler's book on DSL, but indeed that book is from 2005, IIRC. That's a bit old :). According to this site[1] Rails 1.0 was released in December 2005. Rails 4.0 was released in June 2013. Ouch, that was 2010, my bad. I

Re: Is it possible to handle 'magic' property assignments a'la PHP?

2014-01-05 Thread Philippe Sigaud
On Sat, Jan 4, 2014 at 10:08 PM, H. S. Teoh hst...@quickfur.ath.cx wrote: Of course, these are arguably clever hacks than true, properly-motivated examples, but still, they exemplify what Andrei meant when he said that the power of opDispatch is largely still unexplored territory. As Adam

Re: Simplest way to create an array from an associative array which its contains keys and values?

2014-01-05 Thread Philippe Sigaud
On Sat, Jan 4, 2014 at 1:08 AM, Ali Çehreli acehr...@yahoo.com wrote: 3) The member rangeFront is needed because Tuple does not have opIndex for dynamic indexes. I can do range.front[0] but I cannot do range.front[currentIndex]. Is there any plan to add indexing on runtime indices to Tuple?

Re: Is it possible to handle 'magic' property assignments a'la PHP?

2014-01-05 Thread Philippe Sigaud
On Sun, Jan 5, 2014 at 5:18 PM, Jacob Carlborg d...@me.com wrote: Just for the record. In Rails, that's the old, now discourage, Rails 2 syntax. I didn't know that, thanks. I read it during the holidays in Martin Fowler's book on DSL, but indeed that book is from 2005, IIRC. In Rails 3 and

Re: Simplest way to create an array from an associative array which its contains keys and values?

2014-01-05 Thread Philippe Sigaud
On Sun, Jan 5, 2014 at 4:49 PM, Timon Gehr timon.g...@gmx.ch wrote: On 01/05/2014 03:55 PM, Philippe Sigaud wrote: Is there any plan to add indexing on runtime indices to Tuple? It can be done, by generating a specific runtime opIndex for Tuple, if the types held in the tuple have a common

Re: Function declaration

2013-12-26 Thread Philippe Sigaud
On Thu, Dec 26, 2013 at 1:16 AM, Casper Færgemand\ shortt...@hotmail.com@puremagic.com wrote: On Wednesday, 25 December 2013 at 21:23:23 UTC, Philippe Sigaud wrote: I'll consider that as a D grammar question, and not a Pegged-specific question, since Pegged just uses a copy of the D site

<    1   2   3   4   5   6   7   8   9   10   >