Re: question about foreach, opApply, and delegates

2009-06-08 Thread downs
Jerry Quinn wrote: > Hi, all. I find myself a little confused about how foreach, opApply, and > delegates interact according to the docs. > > Foreach on an aggregate will use the opApply call (assuming ranges aren't > being used). So if we use a simple example below, what exactly is the > del

Re: Reminds me of?

2009-07-03 Thread downs
Don wrote: > Steve Teale wrote: >> To the D Faithful: >> >> In recent postings, I have increasingly seen references to the >> 'Select Few'. >> >> This kind of reminds me of Iran, where you have 'The Guardian > Council', and 'The Supreme Leader'. > > The similarities are pretty weak, I'd say. > Wh

Re: cast(public)

2009-07-17 Thread downs
dsimcha wrote: > I know I've probably mentioned this one here before, but it was buried in long > threads. > > Could we put a feature in the language that allows private member variables to > be cast to public? The idea is that, if a class/struct designer makes > something private, they're saying

Re: cast(public)

2009-07-18 Thread downs
Ary Borenszweig wrote: > downs escribió: >> dsimcha wrote: >>> I know I've probably mentioned this one here before, but it was >>> buried in long >>> threads. >>> >>> Could we put a feature in the language that allows private member >

Re: Properties -- another one that gets me

2009-07-29 Thread downs
Bill Baxter wrote: > Just remembered this other real example of a D property that caused me > discomfort: > > .transform > > I wanted it to be an unambiguous property that returns the transform > of an object, but it's too easy to misinterpret as an action that > transforms the object if it can

Re: Properties -- another one that gets me

2009-07-29 Thread downs
Bill Baxter wrote: > On Wed, Jul 29, 2009 at 8:11 AM, downs wrote: >> Bill Baxter wrote: >>> Just remembered this other real example of a D property that caused me >>> discomfort: >>> >>> .transform >>> >>> I wanted it to be an u

A simple rule

2009-07-30 Thread downs
In this post, I present a simple rule of thumb that covers most cases of the common decision: should a feature go in the compiler, or in the standard library? Note: this only applies to features that aren't in C. 1) If it's a word, put it in the standard library. 2) Otherwise, put it in the com

Re: A simple rule

2009-07-30 Thread downs
Walter Bright wrote: > downs wrote: >> As it stands, the claim on the homepage that it's easier to implement >> a D compiler than a C++ one is highly dubious. > > Since I'm the only person to have implemented both, I think I'm in a > good position to judge

Re: A simple rule

2009-07-30 Thread downs
language_fan wrote: > Thu, 30 Jul 2009 21:57:33 +0200, downs thusly wrote: > >> As it stands, the claim on the homepage that it's easier to implement a >> D compiler than a C++ one is highly dubious. > > Isn't D simpler to implement than C++ because the

Re: A simple rule

2009-07-30 Thread downs
To clarify for a few criticisms that have come up in IRC: this is meant as a rule of thumb to fall back on where no other considerations are present. For instance, const and shared are type constructors, and as such hard to do in the standard library. To my knowledge, assert() for instance has

Re: A simple rule

2009-07-30 Thread downs
downs wrote: > Walter Bright wrote: >> downs wrote: >>> As it stands, the claim on the homepage that it's easier to implement >>> a D compiler than a C++ one is highly dubious. >> Since I'm the only person to have implemented both, I think I'm in a

Re: A simple rule

2009-07-30 Thread downs
Michiel Helvensteijn wrote: > downs wrote: > >> 1) If it's a word, put it in the standard library. >> 2) Otherwise, put it in the compiler. > > What an interesting theory. > >> For example: >> >> assert() -> library. > > Compile-tim

Re: A simple rule

2009-07-31 Thread downs
Lars T. Kyllingstad wrote: > downs wrote: >> To clarify for a few criticisms that have come up in IRC: this is >> meant as a rule of thumb to fall back on where no other considerations >> are present. >> >> For instance, const and shared are type constructors,

Re: A simple rule

2009-07-31 Thread downs
Sergey Gromov wrote: > Thu, 30 Jul 2009 21:57:33 +0200, downs wrote: > >> 1) If it's a word, put it in the standard library. >> 2) Otherwise, put it in the compiler. >> >> For example: >> >> assert() -> library. >> complex -> library. &g

Re: A simple rule

2009-07-31 Thread downs
Leandro Lucarella wrote: > downs, el 30 de julio a las 22:31 me escribiste: >> To clarify for a few criticisms that have come up in IRC: this is meant as a >> rule of thumb to fall back on where no other considerations are present. >> >> For instance, const and shared

Re: Iterators Must Go video online

2009-08-04 Thread downs
grauzone wrote: > Daniel Keep wrote: >> >> grauzone wrote: >>> torhu wrote: On 03.08.2009 19:47, Andrei Alexandrescu wrote: > A while ago I mentioned the video of my BoostCon keynote "Iterators > Must > Go" will be soon available online. Here it is: > > http://boostcon.blip

Re: It's awfully quiet

2009-08-18 Thread downs
BCS wrote: > Reply to Jarrett, > >> On Mon, Aug 17, 2009 at 7:42 PM, Paul D. >> Anderson wrote: >>> It's awfully quiet on the newsgroup today. Does that mean Walter is >>> busy getting the new release ready? >>> >>> Or does it only mean I'm not getting new posts :( >>> >>> Suspiciously, >>> >>> Pa

Re: It's awfully quiet

2009-08-19 Thread downs
Lars T. Kyllingstad wrote: > Tim Matthews wrote: >> Jarrett Billingsley Wrote: >> >>> On Mon, Aug 17, 2009 at 7:42 PM, Paul D. >>> Anderson wrote: It's awfully quiet on the newsgroup today. Does that mean Walter is busy getting the new release ready? Or does it only mean I'm not

Re: Reference value of structs not optimized or inlined?

2009-08-28 Thread downs
Walter Bright wrote: > Jeremie Pelletier wrote: >> Isn't it possible to make 'const ref S' or 'in S' generate the same >> machine code as 'in S*'? To me it would seem the semantics of the two >> are the same, with 'const S*' being useful syntax for C compatibility >> while 'in S' and 'const ref S'

Re: OT: What's your favorite codeline?

2009-08-30 Thread downs
I think a favorite line of D code should have a feature of D that >> doesn't appear in any other language... > > I've heard a d guru known as 'downs' is the master of obfuscated one- > liners. Well I wouldn't call myself a 'guru' .. 'mutilator&#

Re: OT: What's your favorite codeline?

2009-09-02 Thread downs
Robert Fraser wrote: > downs wrote: >> foo.betweens("src=\"", "\"") /select/ (string s) { return >> s.find(criteria) != -1; } > > Heh, I love that infix expression syntax. Too abd it ends up with a > completely useless wrapper struct &

Re: Writing a language parser in D

2009-09-15 Thread downs
Justin Johansson wrote: > Can D people please recommend suitable tools for generating a parser (in D) > for an LL(1) grammar. There's bound to be much better parser generator tools > available nowadays, since my last foray into this area 10+ years ago with > YACC. I've heard of tools like biso

Parsing with tools.rd: idc.pad

2009-09-16 Thread downs
Justin Johansson wrote: > > downs Wrote: > > >> >> Justin Johansson wrote: >>> >>> Can D people please recommend suitable tools for generating a parser >>> >>> (in D) for an LL(1) grammar. There's bound to be much better parser

Parsing with tools.rd: idc.pad

2009-09-16 Thread downs
Justin Johansson wrote: >downs Wrote: >> >> Justin Johansson wrote: >>> Can D people please recommend suitable tools for generating a parser (in D) >>> for an LL(1) grammar. There's bound to be much better parser generator >>> tools available

Re: Elliotte Rusty Harold's take on Java

2009-09-17 Thread downs
Nick Sabalausky wrote: > "Justin Johansson" wrote in message > news:h8ruu1$1qp...@digitalmars.com... >> Being somewhat of a fan of Elliotte Rusty Harold, I drop in for a coffee & >> read at his cafes from time to time. I think D people will enjoy this >> December 2008 article with amusement so

Re: memset and related things

2009-09-21 Thread downs
language_fan wrote: > Sun, 20 Sep 2009 18:16:37 -0400, bearophile thusly wrote: > >> My benchmarks aren't chosen randomly, I naturally focus on things that >> are slower in D, so sometimes you can see Java to "win". I usually >> discard the code where Java results slower :-) > > I have seen peopl

Why not move cast to the standard library?

2009-09-24 Thread downs
With all the neat template tricks we have in 2.0, and since we're widely redefining the syntax anyway, why not deprecate the current cast syntax and move it into object.d as a library function? So instead of cast(Foo) bar; you would say cast!Foo(bar); .. save on a keyword and demonstrate langua

Re: Why not move cast to the standard library?

2009-09-24 Thread downs
Andrei Alexandrescu wrote: > downs wrote: >> With all the neat template tricks we have in 2.0, and since we're >> widely redefining the syntax anyway, why not deprecate the current >> cast syntax and move it into object.d as a library function? >> >> So instea

Re: How does one ask a non-invasive question on this (or any other) forum?

2009-09-24 Thread downs
bearophile wrote: > Justin Johansson: >> See subject line > > You can't. All questions here will be scrupulously scrubbed, looking for > subversive ideas or hidden irony, and if something is found they invariably > spout and blossom into invasive threads of often pointless but interesting > dis

Re: Why not move cast to the standard library?

2009-09-24 Thread downs
Jeremie Pelletier wrote: > grauzone wrote: >> Andrei Alexandrescu wrote: >>> downs wrote: >>>> Andrei Alexandrescu wrote: >>>>> downs wrote: >>>>>> With all the neat template tricks we have in 2.0, and since we're >&

Re: Why not move cast to the standard library?

2009-09-24 Thread downs
language_fan wrote: > Thu, 24 Sep 2009 13:47:21 -0400, Steven Schveighoffer thusly wrote: > >> I actually prefer the compiler to handle the casting versus templates to >> cut down on template instantiation bloat. > > I wonder how D scales to 100 MLOC programs as the template instantiations > can

Re: Why not move cast to the standard library?

2009-09-24 Thread downs
Jeremie Pelletier wrote: > downs wrote: >> Jeremie Pelletier wrote: >>> grauzone wrote: >>>> Andrei Alexandrescu wrote: >>>>> downs wrote: >>>>>> Andrei Alexandrescu wrote: >>>>>>> downs wrote: >>>>&

Re: Why not move cast to the standard library?

2009-09-24 Thread downs
Jeremie Pelletier wrote: > downs wrote: >> Jeremie Pelletier wrote: >>> downs wrote: >>>> Jeremie Pelletier wrote: >>>>> grauzone wrote: >>>>>> Andrei Alexandrescu wrote: >>>>>>> downs wrote: >>>>>&g

Re: Null references redux

2009-09-27 Thread downs
Walter Bright wrote: > Nick Sabalausky wrote: > > I agree with you that if the compiler can detect null dereferences at > compile time, it should. > > >>> Also, by "safe" I presume you mean "memory safe" which means free of >>> memory corruption. Null pointer exceptions are memory safe. A null >

Re: Null references redux

2009-09-27 Thread downs
Denis Koroskin wrote: > On Sun, 27 Sep 2009 03:01:48 +0400, Walter Bright > wrote: > >> Denis Koroskin wrote: >>> One more: >>> T foo(bool someCondition) >>> { >>> T? t; >>> if (someCondition) t = someInitializer(); >>> // ... >>> if (t.isNull) { // not initialized yet >>>

Re: Null references redux

2009-09-27 Thread downs
Jeremie Pelletier wrote: > Jarrett Billingsley wrote: >> On Sat, Sep 26, 2009 at 11:23 PM, Jeremie Pelletier >> wrote: >> >>> There is no such thing as "not being able to happen" :) >>> >>> Object thisCannotPossiblyBeNullInAnyWayWhatsoever = cast(Object)null; >>> >>> I seem to be the only one who

Re: Null references redux

2009-09-27 Thread downs
Jeremie Pelletier wrote: > Christopher Wright wrote: >> Jeremie Pelletier wrote: >>> What if using 'Object obj;' raises a warning "unitialized variable" >>> and makes everyone wanting non-null references happy, and 'Object obj >>> = null;' raises no warning and makes everyone wanting to keep the >>

Re: Null references redux

2009-09-27 Thread downs
Jeremie Pelletier wrote: > Andrei Alexandrescu wrote: >> downs wrote: >>> Walter Bright wrote: >>>> Nick Sabalausky wrote: >>>> >>>> I agree with you that if the compiler can detect null dereferences at >>>> compile time, it should

Re: Null references redux

2009-09-27 Thread downs
Jeremie Pelletier wrote: > downs wrote: >> Jeremie Pelletier wrote: >>> Christopher Wright wrote: >>>> Jeremie Pelletier wrote: >>>>> What if using 'Object obj;' raises a warning "unitialized variable" >>>>> an

Re: opEquals and the Non-Virtual Interface idiom

2009-09-27 Thread downs
Jeremie Pelletier wrote: > grauzone wrote: >> Andrei Alexandrescu wrote: >>> Here's an article about the perils of equals in Java (opEquals in D): >>> >>> http://www.ddj.com/article/printableArticle.jhtml;jsessionid=GFKUCQH5S4IHNQE1GHOSKHWATMY32JVN?articleID=184405053&dept_url=/java/ >>> >>> >>> It

Re: Multiple subtyping with alias this and nested classes

2009-10-02 Thread downs
language_fan wrote: > Fri, 02 Oct 2009 19:35:55 -0300, Leandro Lucarella thusly wrote: > >> We might have very different taste, but I find that a little... >> horrible. What do you have against mixins? I think you're trying to use >> D as C++ :) > > So basically the diamond problem is again imple

Re: I wrote some D today and it's completely blowing my mind. Ever tried

2009-10-03 Thread downs
Justin Johansson wrote: > Walter Bright Wrote: > >> http://www.reddit.com/r/programming/comments/9qf8i/i_wrote_some_d_today_and_its_completely_blowing/ > > Don't know why you bother with Reddit, Walter. Going by a lot of the replies > there, its a case of > pearls before swine. > > Cheers > --

Re: D2.0 cpp interfacing: what is a C++ unsigned long counterpart in D?

2009-10-04 Thread downs
Denis Koroskin wrote: > I'm currently writing a program that interfaces with C++. > C++ code uses a lot of 'unsigned long', which equals to 'unsigned int', > or just 'unsigned', but is mangled differently. > > In particular, C++ mangles unsigned long as 'K', and I can't find a D > counterpart that

Re: null references redux + Looney Tunes

2009-10-05 Thread downs
bearophile wrote: > Denis Koroskin: > >> I don't see any reason why if (someComplexNumber) { ... } should be a > valid code, it hardly makes any sense for me.< > > In general I think adding a boolean-evaluation standard method to D can be > positive and handy and not that bug-prone. > But comp

Re: Eliminate class allocators and deallocators?

2009-10-06 Thread downs
Andrei Alexandrescu wrote: > Hello, > > > D currently allows defining class allocators and deallocators. They have > a number of problems that make them unsuitable for D 2.0. The most > obvious issue is that D 2.0 will _not_ conflate destruction with > deallocation anymore: invoking delete agains

Re: Eliminate class allocators and deallocators?

2009-10-06 Thread downs
Andrei Alexandrescu wrote: > downs wrote: >> Andrei Alexandrescu wrote: >>> Hello, >>> >>> >>> D currently allows defining class allocators and deallocators. They have >>> a number of problems that make them unsuitable for D 2.0. The mo

Re: Eliminate class allocators and deallocators?

2009-10-07 Thread downs
Andrei Alexandrescu wrote: > downs wrote: >> Andrei Alexandrescu wrote: >>> downs wrote: >>>> Andrei Alexandrescu wrote: >>>>> Hello, >>>>> >>>>> >>>>> D currently allows defining class allocators and dealloc

Re: Eliminate class allocators and deallocators?

2009-10-07 Thread downs
Don wrote: > downs wrote: >> Andrei Alexandrescu wrote: >>> downs wrote: >>>> Andrei Alexandrescu wrote: >>>>> downs wrote: >>>>>> Andrei Alexandrescu wrote: >>>>>>> Hello, >>>>>>> >>>

Re: Eliminate class allocators and deallocators?

2009-10-07 Thread downs
Jeremie Pelletier wrote: > downs wrote: >> Don wrote: >>> downs wrote: >>>> Andrei Alexandrescu wrote: >>>>> downs wrote: >>>>>> Andrei Alexandrescu wrote: >>>>>>> downs wrote: >>>>>>>>

Amusing D facts: typesafe variadic arrays are lazy!

2009-10-13 Thread downs
Did you know the following code compiles? > module test; > > import std.stdio; > > void Assert(bool cond, string delegate()[] dgs...) { > debug if (!cond) { > string str; > foreach (dg; dgs) str ~= dg(); > throw new Exception(str); > } > } > > void main() { > Assert(false, "O hai

Re: Amusing D facts: typesafe variadic arrays are lazy!

2009-10-13 Thread downs
downs wrote: > Did you know the following code compiles? > >> module test; >> >> import std.stdio; >> >> void Assert(bool cond, string delegate()[] dgs...) { >> debug if (!cond) { >> string str; >> foreach (dg; dgs) str ~= dg(); &

Re: Amusing D facts: typesafe variadic arrays are lazy!

2009-10-14 Thread downs
Jeremie Pelletier wrote: > Andrei Alexandrescu wrote: >> Chris Nicholson-Sauls wrote: >>> downs wrote: >>>> >>>> Here is a funny consequence of this amusing fact: >>>> >>>> if you overload opAssign in a stru

What's up anyway -

2009-10-15 Thread downs
Justin Johansson wrote: > - that the .sizeof a delegate is 8 bytes (on a 32-bit machine). > > AFAIK, stack pushes are still more expensive than a pointer dereference in > contemporary > CPU architectures. > > Justin - with this weird way of writing posts? The subject should tell us about the c

Benchmark results: delegate fast, functor no faster, memory allocation slow. Really slow.

2009-10-15 Thread downs
Two discoveries were made from this benchmark. 1) There is no appreciable speed difference between delegates and functors. I re-ran the benchmark several times; sometimes one was faster, sometimes the other - no clear advantage was discernible. The visible differences can be blamed on experimen

Re: Benchmark results: delegate fast, functor no faster, memory allocation slow. Really slow.

2009-10-15 Thread downs
On consideration, this wasn't a test of the two methods at all, but a test of the compiler's ability to inline. Disregard it.

I love -

2009-10-15 Thread downs
Gemaine Frazier wrote: > completely chilled - a glass or two of wine will do that... you all! Except you, weird spacey goat thing. You freak me out. But man this is some FINE weed!

Re: I love -

2009-10-15 Thread downs
Jeremie Pelletier wrote: > Nick Sabalausky wrote: >> "downs" wrote in message >> news:hb83h6$1ht...@digitalmars.com... >>> Gemaine Frazier wrote: >>>> completely chilled - a glass or two of wine will do that... >>> you all! Except you, wei

Re: The demise of T[new]

2009-10-18 Thread downs
Walter Bright wrote: > The purpose of T[new] was to solve the problems T[] had with passing T[] > to a function and then the function resizes the T[]. What happens with > the original? > > The solution we came up with was to create a third array type, T[new], > which was a reference type. > > And

Re: The demise of T[new]

2009-10-18 Thread downs
dsimcha wrote: > == Quote from downs (default_357-l...@yahoo.de)'s article >> Walter Bright wrote: >>> The purpose of T[new] was to solve the problems T[] had with passing T[] >>> to a function and then the function resizes the T[]. What happens with >>> t

Re: The demise of T[new]

2009-10-19 Thread downs
Walter Bright wrote: > Ary Borenszweig wrote: >> I remember seeing a lot of CTFE code that created a dynamic array and >> then appended stuff to it, like for example to build a list of prime >> numbers. Would that still work with ArrayBuilder? > > Probably not. But you can rewrite: > > a ~= stu

Re: static arrays becoming value types

2009-10-19 Thread downs
Walter Bright wrote: > Currently, static arrays are (as in C) half-value types and > half-reference types. This tends to cause a series of weird problems and > special cases in the language semantics, such as functions not being > able to return static arrays, and out parameters not being possible

Re: stack frame optimization problem

2009-10-20 Thread downs
sprucely wrote: > To try to be sure I had the correct syntax I tried the -S option of g++ along > with a switch for intel syntax to output the assembly. However the portion > corresponding to the inline assembly was still in ATT syntax. > > For my resulting D executable I tried using hte, but it

Re: No header files?

2009-10-22 Thread downs
AJ wrote: > "Nick Sabalausky" wrote in message > news:hboum3$1bh...@digitalmars.com... >> "AJ" wrote in message >> news:hbosh1$17l...@digitalmars.com... >>> "Nick Sabalausky" wrote in message >>> news:hbontv$uq...@digitalmars.com... If you want to manually write a separate redundant file

Re: langref.org: cookbook/programming examples

2009-10-25 Thread downs
Walter Bright wrote: > http://langref.org/ > > Need some D versions! http://rosettacode.org/wiki/Category:D is much more complete.

Re: Memory Management in D: Request for Comment

2009-11-03 Thread downs
I submitted a patch a while back for constant-time removeRange. Can we dredge that one up and/or implement something similar? It's rather useful for things like stackthreads that need to add and remove lots of ranges :) (Search the NG for "Feature req.+Patch: O(1) removeRange")

Re: Memory Management in D: Request for Comment

2009-11-03 Thread downs
dsimcha wrote: > == Quote from downs (default_357-l...@yahoo.de)'s article >> I submitted a patch a while back for constant-time removeRange. Can we dredge > that one up and/or implement something similar? It's rather useful for things > like > stackthreads that ne

Re: Memory Management in D: Request for Comment

2009-11-04 Thread downs
dsimcha wrote: > == Quote from downs (default_357-l...@yahoo.de)'s article >> dsimcha wrote: >>> == Quote from downs (default_357-l...@yahoo.de)'s article >>>> I submitted a patch a while back for constant-time removeRange. Can we >>>> dredg

Re: scope(exit) considered FREAKING AWESOME

2009-11-08 Thread downs
auto var = hairilyAllocatedObject(); scope(exit) cleanupObject(var); sock.send(""); scope(exit) sock.send(""); logln("Digraph D {"); scope(exit) logln("}"); SDL_LockSurface(display.surface); scope(exit) SDL_UnlockSurface(display.surface); auto dg = { performComplexExitCleanupDuty; }; scope(exit

Re: scope(exit) considered FREAKING AWESOME

2009-11-08 Thread downs
Justin Johansson wrote: > downs Wrote: > >> auto var = hairilyAllocatedObject(); >> scope(exit) cleanupObject(var); >> >> sock.send(""); >> scope(exit) sock.send(""); >> >> logln("Digraph D {"); >> scope(exit)

Re: Question of delegate literals and return from function(GDC, DMD, LDC)

2009-02-01 Thread downs
amaury pouly wrote: > Hello, > I have a little question about D: I want to have a function returning a > delegate and more precisely a delegate literal that uses one of the arguments > of the function. Here is an example: > > int delegate(int) test(int[] tab) > { > return (int d) > { >

If !in is inconsistent because of bool/pointer, then so is !

2009-02-06 Thread downs
This has been brought up before as an argument against the !in operator (forcing us to resort to such workarounds as /notin/): that the !in operator would have inconsistent syntax with in, because in returns a pointer and !in would return a bool. This is NOT a reason against !in. In fact, this

Re: If !in is inconsistent because of bool/pointer, then so is !

2009-02-06 Thread downs
Rainer Deyke wrote: > downs wrote: >> This is NOT a reason against !in. In fact, this so-called >> "inconsistency" is already present in the language. If we remember, >> !pointer already transforms it into a boolean, so it would actually >> be more consistent i

Re: If !in is inconsistent because of bool/pointer, then so is !

2009-02-07 Thread downs
Bill Baxter wrote: > On Sat, Feb 7, 2009 at 8:54 AM, bearophile wrote: >> Rainer Deyke: >>> It's a question of consistent patterns versus special cases. >> You may think that for humans it's better to have a very orthogonal >> language, like for example Scheme. >> There's also a famous quote abou

Re: Old problem with performance

2009-02-08 Thread downs
Weed wrote: > Christopher Wright пишет: >> Weed wrote: >>> Christopher Wright пишет: Weed wrote: > (Has started here: > http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=81359) > > > > To me still does not give rest performance of clas

Re: primitive vector types

2009-02-20 Thread downs
Daniel Keep wrote: > Andrei Alexandrescu wrote: >> Denis Koroskin wrote: >>> On Thu, 19 Feb 2009 22:25:04 +0300, Mattias Holm >>> wrote: >>> Since (SIMD) vectors are so common and every reasonabe system support them in one way or the other (and scalar emulation of this is rather sim

Use case for std.bind

2009-02-23 Thread downs
Let me say first that I don't use std.bind myself, but tools.base:fix fills essentially the same need - creating full closures from dynamic ones. Say you have a function that takes a number and returns a delegate that does something with that number. void delegate() test(int i) { return { retur

Re: Use case for std.bind

2009-02-24 Thread downs
Yigal Chripun wrote: > Lars Kyllingstad wrote: >> I've always thought currying was the main point of std.bind. If I'm not >> mistaken, currying is commonly a built-in feature of functional >> programming languages, so if anything, std.bind could become more >> useful/important in D2 than in D1. >>

Re: First class lazy Interval

2009-02-28 Thread downs
Andrei Alexandrescu wrote: > bearophile wrote: >> As an alternative syntax may be: >> >> foreach (i; 1:10) {...} >> foreach (i; 10 : 1 : -1) {...} >> foreach (i; 0.0 : 10.5 : 0.5) {...} > > I have an idea - we define a contextual keyword "iota" that helps us > specify from, to, and stride. Then we

Re: const?? When and why? This is ugly!

2009-03-02 Thread downs
Andrei Alexandrescu wrote: > D is positioned very well, probably uniquely, to take advantage of a > default-isolated model within a largely mutative language, and that is > in no small part due to const and immutable. Other languages are > struggling, see http://tinyurl.com/4apat7. I'm very glad th

Re: opImplicitCast

2009-03-22 Thread downs
dsimcha wrote: > Is opImplicitCast (and fixing opCast) anywhere in the pipeline? It seems like > every time I want to create an interesting library type, lack of > opImplicitCast prevents me from making its API nice enough to be worth doing. > In some cases, alias this, which has been proposed,

FWIW: How to allocate any type

2009-03-23 Thread downs
struct Temp(T) { T t; } T* allocate(T)() { auto wrap = new Temp!(T); return &wrap.t; }

Re: what are the most common bugs in your D apps?

2009-04-05 Thread downs
davidl wrote: > > Actually I'm not sure about what kind of bugs my d apps usually have. > But I notice that the harmonia project(I now make it uptodate) gets the > problem of integer overlapping(actually I find it quite hard to detect > and fix). > > What's your opinion and experience? I'd say i

Re: minimal evaluation

2009-04-06 Thread downs
Qian Xu wrote: > Hi All, > > Is minimal evaluation always enabled in D? > > I want to write a function IsNull(), so that I can check the precondition as > follows: > > if (isNull(foo) || > isNull(foo.getBar) || > isNull(foo.getBar.getBar2) > { > return false; > } > // nor

Re: minimal evalu-OMG COOKIE YAY

2009-04-06 Thread downs
Daniel Keep wrote: > > downs wrote: >> Qian Xu wrote: >>> Hi All, >>> >>> Is minimal evaluation always enabled in D? >>> >>> I want to write a function IsNull(), so that I can check the precondition as >>> follows: >>>

Re: D, so it happend...

2009-04-06 Thread downs
Ellery Newcomer wrote: > Baas wrote: >> Tech info: >> - Parse the code into XML using Regular Expressions. > > *double take* It's all about the better optimizations that are now possible!

Re: D, so it happend...

2009-04-06 Thread downs
Bass wrote: > downs Wrote: > >> Ellery Newcomer wrote: >>> Baas wrote: >>>> Tech info: >>>> - Parse the code into XML using Regular Expressions. >>> *double take* >> It's all about the better optimizations that are now possible! &

Re: minimal evaluation

2009-04-07 Thread downs
TomD wrote: > Qian Xu Wrote: > >> Hi All, >> >> Is minimal evaluation always enabled in D? >> >> I want to write a function IsNull(), so that I can check the precondition as >> follows: >> >> Â if (isNull(foo) || >> Â Â Â isNull(foo.getBar) || >> Â Â Â isNull(foo.getBar.getBar2) >> Â { >>

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread downs
Andrei Alexandrescu wrote: > Denis Koroskin wrote: >> On Fri, 17 Apr 2009 18:24:04 +0400, Steven Schveighoffer >> wrote: >> >>> On Fri, 17 Apr 2009 09:44:09 -0400, Leandro Lucarella >>> wrote: >>> I don't fully understand the example though. In writefln((v.qq = 5).i), how is that B.i i

Re: Fully dynamic d by opDotExp overloading

2009-04-18 Thread downs
bearophile wrote: > downs: >> Static loops are simple, at least in functions. >> ... >> void main() { >> foreach (i, bogus; Repeat!(void, 15)) >> writefln(i); >> } > > My dlibs have: > Range!([start], stop[, step]) > with it I think you

Re: Fully dynamic d by opDotExp overloading

2009-04-19 Thread downs
Daniel Keep wrote: > > bearophile wrote: >> downs: >>> bearophile: >>>> But a static foreach (on a static data structure that has opApply) is not >>>> doable yet, I think. >>> Foreach on a tuple is evaluated at compile-time. >> Yes, t

Re: temporary objects are not allowed to be pass by ref anymore

2009-04-19 Thread downs
Denis Koroskin wrote: > What's a rationale behind an issue described bug 2621? > http://d.puremagic.com/issues/show_bug.cgi?id=2621 > > Why isn't it allowed anymore? > > It broke quite a lot of my code. And while it is fixable by doing > > auto tmp = someFunctionThatRetunsStruct(); > someMethodT

Automated rebuilding on program startup: tools.remake

2009-04-21 Thread downs
I just committed tools/remake.d. What it does in a nutshell is this: it lets you add a call in your main.d file, along the lines of checkRemake(args, "path/to/source/file.d"); checkRemake invokes gdc (or a compiler of choice, via string Compiler), in verbose mode, to generate a list of import

Re: Automated rebuilding on program startup: tools.remake

2009-04-21 Thread downs
Saaa wrote: > Instead of running build/bud you could run your old program to rebuild > itself? > That's the idea! :) >> I just committed tools/remake.d. What it does in a nutshell is this: >> >> it lets you add a call in your main.d file, along the lines of >> >> checkRemake(args, "path/to/sou

Re: member arguments in D? (solution for Phobos

2009-04-26 Thread downs
Nick Sabalausky wrote: > "Daniel Keep" wrote in message > news:gt159p$1bq...@digitalmars.com... >> >> Penguin wrote: >>> What do you think about: >>> >>> class Foo { >>> >>>int a; >>>float b; >>> >>>this( member a, member b ) { >>> >>>} >>> >>> } >>> >>> instead of: >>> >>> class

Re: member arguments in D? (solution for Phobos

2009-04-26 Thread downs
DisForDave wrote: > downs Wrote: > >> Nick Sabalausky wrote: >>> "Daniel Keep" wrote in message >>> news:gt159p$1bq...@digitalmars.com... >>>> Penguin wrote: >>>>> What do you think about: >>>>> >>>>

Re: Simple D program - Segmentation Fault

2009-04-26 Thread downs
Dan900 wrote: > I tried to compile this code using > > gdc -o dodawanie dodawanie.d > > import std.stdio; > void main() { > int a = 6, b = 7; > writefln(a+b); // wynik dodawania nie zostanie zapisany do zmiennej > // tylko od razu przekazany funkcji writefln

This and ElemType are also in tools.base.

2009-04-27 Thread downs
bearophile wrote: > dsimcha Wrote: >> I've been thinking a little more about ranges, etc. and it would be nice to >> have a template for isIterable(T) > > I agree. > IsIterable is already inside my dlibs (as the xkeys/xvalues you talk about in > another post of yours, but in the "func" module), i

Re: Splitter quiz / survey -- PLEASE NO

2009-04-27 Thread downs
Andrei Alexandrescu wrote: > bearophile wrote: >> Andrei Alexandrescu: >>> Splitter does what Perl's split does: 2. >> >> Perl has to die. This is Python: > > This answer is wrong for a number of reasons. First comes the fallacy > that if Perl "has to die", everything Perl did was wrong. Second co

Re: Yet another strike against the current AA implementation

2009-04-28 Thread downs
Daniel Keep wrote: > > Michel Fortin wrote: >> On 2009-04-27 10:51:22 -0400, Frits van Bommel >> said: >> >>> I edited this code to work with ldc (D1) + Tango, and saw the Direct >>> and opApply cases generate identical code (inc, cmp, jne, with the >>> loop counter in a register) [1], so they're

Re: Yet another strike against the current AA implementation

2009-04-28 Thread downs
Joel C. Salomon wrote: > grauzone wrote: >> downs wrote: >>> Daniel Keep wrote: >>>> Here's an excellent reason to use ranges over opApply: you >>>> can't define zip with opApply. Because opApply uses inversion of >>>> contro

  1   2   >