Re: To help LDC/GDC

2013-04-09 Thread Pelle Månsson
On Tuesday, 9 April 2013 at 13:49:12 UTC, Dicebot wrote: On Tuesday, 9 April 2013 at 12:56:04 UTC, Andrei Alexandrescu wrote: It is valid code. It is "weak pure". "pure' keyword means both "strong pure" or "weak pure" depending on function body. Crap. s/body/signature/ s/Crap/Awesome/ Not go

Re: arrays and .sizeof

2011-08-09 Thread Pelle
On Tue, 09 Aug 2011 14:38:21 +0200, Trass3r wrote: I've encountered this problem several times now and almost always it takes hours or days to reduce crashes down to this. The sizeof property works as expected for static arrays, but as soon as you change the array to a dynamic one (e.g. caus

Re: Wider tuple design discussion

2011-08-02 Thread Pelle
On Tue, 02 Aug 2011 15:15:52 +0200, bearophile wrote: 5.1) The most basic one is unpacking a tuple locally, inside a function. 5.2) Another common situation is unpacking a small tuple inside a foreach statement, when you iterate on a collection of tuples. I would argue these two are the m

Re: opBinary failes with templates

2011-07-28 Thread Pelle
On Wed, 27 Jul 2011 22:46:21 +0200, Steven Schveighoffer wrote: The proper workaround (and actually, the cleaner solution) is to use Vector and not Vector!D. Inside a template, the name of the template is the same as if you invoked the template with the same template parameters. If you

Re: Ceylon language

2011-04-15 Thread Pelle
On 04/15/2011 03:23 AM, Nick Sabalausky wrote: I'm not certain either, but I *think* partial application is just like currying except there's some sort of arbitrary limitaion on what combination(s) of paramaters you can choose to specify or not specify. And that limitation is based purely on what

Re: back down on Earth [was: Re: Constructors...]

2011-01-22 Thread Pelle
On 01/21/2011 02:02 PM, spir wrote: On 01/21/2011 04:02 AM, Andrei Alexandrescu wrote: That being said, it's not difficult to define a generic function that copies fields over from one class object to another. Here's a start: import std.stdio; void copyMembers(A)(A src, A tgt) if (is(A == clas

Re: Issue 1323

2011-01-09 Thread Pelle
On 01/09/2011 03:07 AM, Robert Clipsham wrote: On 08/01/11 23:20, bearophile wrote: Andrei has recently closed issue 1323, it's a small but very useful feature, so I suggest some public discussion: http://d.puremagic.com/issues/show_bug.cgi?id=1323 Lines like this is present thousands of time i

Re: Why is D slower than LuaJIT?

2010-12-23 Thread Pelle Månsson
On 12/22/2010 11:04 PM, Andreas Mayer wrote: To see what performance advantage D would give me over using a scripting language, I made a small benchmark. It consists of this code: auto L = iota(0.0, 1000.0); auto L2 = map!"a / 2"(L); auto L3 = map!"a + 2"(L2); auto V = redu

Re: Threads and static initialization.

2010-12-18 Thread Pelle Månsson
On 12/18/2010 10:00 AM, Jonathan M Davis wrote: The problem is that the OP wants the static constructors to be skipped. If they're skipped, anything and everything which could be affected by that can't be used. That pretty much means not using TLS, since the compiler isn't going to be able to tr

Re: Threads and static initialization.

2010-12-18 Thread Pelle Månsson
On 12/18/2010 07:53 AM, Jonathan M Davis wrote: On Friday 17 December 2010 19:52:19 Vladimir Panteleev wrote: On Sat, 18 Dec 2010 03:06:26 +0200, Jonathan M Davis wrote: And how about every other variable? I'm sorry, I'm not following you. What other variables? * Globals and class/struct/fu

Re: Binary heap method to update an entry.

2010-12-17 Thread Pelle Månsson
On 12/16/2010 04:53 PM, Andrei Alexandrescu wrote: On 12/16/10 7:55 AM, Matthias Walter wrote: On 12/16/2010 04:17 AM, Andrei Alexandrescu wrote: On 12/15/10 10:21 PM, Matthias Walter wrote: Hi all, I uploaded [1] a patch for std.container to use BinaryHeap as a priority queue. For the latter

Re: emscripten

2010-12-16 Thread Pelle Månsson
On 12/15/2010 03:17 PM, Michael Stover wrote: And that's the problem - we're talking about applications that happen to be distributed via the web, not a "website". Everyone's demands that it work in lynx, FF2, with javascript turned off, etc are ludicrous. I disagree. You don't get to make s

Re: New syntax for string mixins

2010-12-16 Thread Pelle Månsson
On 12/15/2010 11:00 PM, Nick Sabalausky wrote: "Jonathan M Davis" wrote in message news:mailman.1035.1292441722.21107.digitalmar...@puremagic.com... On Wednesday, December 15, 2010 11:27:47 Jacob Carlborg wrote: That was my idea as well, that @get_set("int", "bar"); could be translated into

Re: String compare performance

2010-11-28 Thread Pelle Månsson
On 11/28/2010 04:48 PM, bearophile wrote: Pelle Månsson: I don't have your data set, In my first post I have explained how to create the data set, using a little Python script that I have listed there. You just need a Python2 interpreter. but for me using random data this was wit

Re: String compare performance

2010-11-28 Thread Pelle Månsson
On 11/28/2010 12:44 PM, bearophile wrote: Robert Jacques: I've spent some time having fun this afternoon optimizing array-equals using vectorization techniques. I found that vectorizing using ulongs worked best on my system except with the shortest strings, where a simple Duff's device edged it

Re: Passing dynamic arrays

2010-11-26 Thread Pelle Månsson
On 11/26/2010 07:22 PM, Bruno Medeiros wrote: But more importantly, there is a simple solution: don't write such code, don't use arrays like if they are lists, preallocate instead and then fill the array. So with this alternative behavior, you can still write efficient code, and nearly as easily.

Re: DIP9 -- Redo toString API

2010-11-21 Thread Pelle Månsson
On 11/21/2010 09:37 PM, Jacob Carlborg wrote: Inside to!string, it would be something like this: string s; arg.writeTo((const(char)[] data) { s ~= data; }); return s; Why can't toString do the same ? Because then you'd have to write it? I'm afraid I don't understand.

Re: DIP9 -- Redo toString API

2010-11-21 Thread Pelle Månsson
On 11/21/2010 09:49 PM, spir wrote: (Sorry for the irony.) "Make simple things easy." Have to write a delegate to get feedback... to print a bit of text. (What is "hello, world!" in D?) Missing the point, are we? Hello world is unchanged.

Re: DIP9 -- Redo toString API

2010-11-21 Thread Pelle Månsson
On 11/21/2010 03:17 PM, spir wrote: No, just use toString. As said above, I don't want to writeTo, I want the string; and be free to do whatever I want to with it. Being only able to write is... (rather censure). I... don't think you understand what writeTo is supposed to do. Inside to!strin

Re: DIP9 -- Redo toString API

2010-11-21 Thread Pelle Månsson
On 11/21/2010 11:10 AM, spir wrote: What I do not want is tostring be deprecated in any case. The proposal would be OK if it introduced an _alternative_ for the cases (?) where string output efficiency is relevant. The language could/should default to writeTo is toString is not defined, *and*

Re: Principled method of lookup-or-insert in associative arrays?

2010-11-20 Thread Pelle Månsson
On 11/20/2010 05:09 PM, spir wrote: ??? backdoor and s do not denote the same element. One is a mutable array, the other is immutable. Why should changing backdoor affect s? Whether backdoor and chars denote the same array depends on whether "=" copies or not dyn arrays. But from immutable str

Re: Function, signatures and tuples

2010-11-16 Thread Pelle Månsson
On 11/13/2010 11:43 AM, Russel Winder wrote: On Sat, 2010-11-13 at 08:18 +, Iain Buclaw wrote: [ . . . ] import std.typecons; ? Hummm... I thought I had put that in but clearly I had not :-(( OK so that explains the bulk of the problems on this code, I knew it was something stupid on my p

[OT] Re: Passing dynamic arrays -- example *reference* array type

2010-11-09 Thread Pelle Månsson
On 11/09/2010 09:36 AM, spir wrote: On Mon, 8 Nov 2010 17:08:32 -0800 Jonathan M Davis wrote: As Jesse says, they _are_ passed by reference. The struct itself _is_ the reference. (Well, that is a sensible redefinition of "reference"; but it is simply _not_ what the word means in any other c

Re: The D Scripting Language

2010-11-09 Thread Pelle Månsson
On 11/09/2010 06:12 PM, Andrei Alexandrescu wrote: On 11/7/10 9:12 PM, Eric Poggel wrote: On 11/7/2010 8:49 PM, Andrei Alexandrescu wrote: On 11/7/10 5:34 PM, Jesse Phillips wrote: Tomek Sowiñski Wrote: This wraps up a thread from a few days ago. Pascal featured my D examples on his Scriptom

Re: Spec#, nullables and more

2010-11-05 Thread Pelle Månsson
On 11/06/2010 12:41 AM, Walter Bright wrote: Denis Koroskin wrote: On Fri, 05 Nov 2010 23:44:58 +0300, Walter Bright wrote: To eliminate null pointers is the same as shooting the canary in your coal mine because its twitter annoys you. I'm tired of pointing out that NO ONE is talking about

Re: Spec#, nullables and more

2010-11-05 Thread Pelle Månsson
On 11/05/2010 08:30 PM, bearophile wrote: Denis Koroskin: Is anyone FORCING you to use non-nullable references? What's the big deal? If non-nullables are introduced in D3, then Phobos will start to use them. So probably you can't avoid using some of them. Bye, bearophile If we're still fo

Re: Spec#, nullables and more

2010-11-05 Thread Pelle Månsson
On 11/05/2010 02:56 PM, Gary Whatmore wrote: Pelle Månsson Wrote: On 11/05/2010 02:39 PM, Kagamin wrote: bearophile Wrote: Spec# adds only few things to C# 2.0: - Non-nullable types; It's hard to tell, whether they fix anything. When you cast nullable to non-nullable, you get

Re: Spec#, nullables and more

2010-11-05 Thread Pelle Månsson
On 11/05/2010 03:04 PM, Kagamin wrote: Pelle Månsson Wrote: Getting the error early is actually a lot better than getting the error late. OK, but it doesn't reduce the number of bugs. You had an error with nullables and you still has error with non-nullables. But in the non-nul

Re: Spec#, nullables and more

2010-11-05 Thread Pelle Månsson
On 11/05/2010 02:48 PM, Gary Whatmore wrote: Pelle Månsson Wrote: On 11/05/2010 12:43 PM, Gary Whatmore wrote: bearophile Wrote: - A way to list what attributes are modified in a method (similar to my @outer). The compiler should do this itself. Doesn't make sense. My reference

Re: Spec#, nullables and more

2010-11-05 Thread Pelle Månsson
On 11/05/2010 02:39 PM, Kagamin wrote: bearophile Wrote: Spec# adds only few things to C# 2.0: - Non-nullable types; It's hard to tell, whether they fix anything. When you cast nullable to non-nullable, you get your runtime exception as usual, if you if out access to nullable (e.g. in delay

Re: Spec#, nullables and more

2010-11-05 Thread Pelle Månsson
On 11/05/2010 12:43 PM, Gary Whatmore wrote: bearophile Wrote: - A way to list what attributes are modified in a method (similar to my @outer). The compiler should do this itself. Doesn't make sense. My reference issue: http://d.puremagic.com/issues/show_bug.cgi?id=4571 Walter, please cl

Re: Why struct opEquals must be const?

2010-10-18 Thread Pelle
On 10/18/2010 05:55 PM, Steven Schveighoffer wrote: On Mon, 18 Oct 2010 11:19:54 -0400, Pelle wrote: On 10/18/2010 05:07 PM, Steven Schveighoffer wrote: What case were you thinking of for requiring mutablity for equality testing? -Steve I was thinking along the lines of not enforcing

Re: Why struct opEquals must be const?

2010-10-18 Thread Pelle
On 10/18/2010 05:07 PM, Steven Schveighoffer wrote: On Mon, 18 Oct 2010 10:49:25 -0400, Pelle wrote: Shouldn't the compiler make the opEquals non-const if one of the struct members requires mutability for equality testing? Just a thought. IMO, opEquals should allow non-const, but on

Re: The Next Big Language

2010-10-18 Thread Pelle
On 10/18/2010 03:18 PM, Paulo Pinto wrote: Yes, here is a summary of programming languages killer features. C - The official language to develop for Unix C++ - Provided a path for OOP programming to C developers, created at the same company that "owned" Unix Pascal - Provided a very goo

Re: Why struct opEquals must be const?

2010-10-18 Thread Pelle
On 10/18/2010 02:41 PM, Steven Schveighoffer wrote: On Sun, 17 Oct 2010 02:57:02 -0400, Nick Sabalausky wrote: Is there a technical reason why the l- and r- values for opEquals must be const? If the restriction is purely for the intuitive notion that there's no heisenstructs, then I have an ex

Re: std.algorithm.remove and principle of least astonishment

2010-10-16 Thread Pelle
On 10/16/2010 09:56 PM, klickverbot wrote: On 10/16/10 9:47 PM, Andrei Alexandrescu wrote: Thanks for the input. This is not a bug, it's what I believe to be a very intentional feature: strings are not ordinary arrays because characters have variable length. As such, assigning to "the first char

Re: Streaming transport interfaces: input

2010-10-14 Thread Pelle
On 10/14/2010 05:34 PM, Andrei Alexandrescu wrote: Starting a new thread from Denis' question: Can we outline basic Stream interface now so that we could move on? Here's the input transport layer. Transport has no concern for formatting - it just moves stuff around. interface TransportBase {

Re: Partial return type specification

2010-10-11 Thread Pelle
On 10/11/2010 10:56 PM, bearophile wrote: Pelle: string assertReturnsRangeOf(T)() { return "static assert (is(Unqual!(ForeachType!(typeof(return))) == " ~ T.stringof ~ "));"; } auto foo() { return map!q{a*a}([1,2,3,4,5]); mixin (assertReturns

Re: improving the join function

2010-10-11 Thread Pelle
On 10/12/2010 02:33 AM, Andrei Alexandrescu wrote: I'm looking at http://d.puremagic.com/issues/show_bug.cgi?id=3313 and that got me looking at std.string.join, which currently has the sig: string join(in string[] words, string sep); A narrow fix: Char[] join(Char)(in Char[][] words, in Char[]

Re: Caching in computing ranges

2010-10-09 Thread Pelle
On 10/09/2010 09:38 PM, Tomek Sowiński wrote: I've been having fun with ranges lately. While nesting computing ranges I noticed only the outermost range's cache is necessary; there's no way of accessing front() of ranges deeper in the expression twice because they are sealed by the outermost ra

Re: What is a tuple and why should one care?

2010-10-08 Thread Pelle
On 10/08/2010 02:37 PM, Justin Johansson wrote: There's a lot of (imho, pointless) discussion going on about tuples in D. I've asked before and haven't any illumination, especially of Walter. In the context of D, can someone please enlighten me as to exactly what a tuple is supposed to be. The

Re: "in" everywhere

2010-10-08 Thread Pelle
On 10/08/2010 01:45 PM, Juanjo Alvarez wrote: Pelle Wrote: On 10/08/2010 03:18 AM, Juanjo Alvarez wrote: On Thu, 7 Oct 2010 15:53:13 -0700, Jonathan M Davis wrote: Except that when you're dealing with generic code which has to deal with multiple container types (like std.algorithm)

Re: "in" everywhere

2010-10-08 Thread Pelle
On 10/08/2010 03:18 AM, Juanjo Alvarez wrote: On Thu, 7 Oct 2010 15:53:13 -0700, Jonathan M Davis wrote: Except that when you're dealing with generic code which has to deal with multiple container types (like std.algorithm), you _need_ certain complexity guarantees about an operation since

Re: "in" everywhere

2010-10-07 Thread Pelle
On 10/07/2010 09:40 PM, bearophile wrote: Andrei Alexandrescu: I'm a bit leary of adopting this feature (it has been discussed). To me "in" implies a fast operation and substring searching isn't quite it. One thing that could be done is to allow "in" with literal arrays to their right: if (x

Re: Tuple assignment

2010-10-07 Thread Pelle
On 10/07/2010 08:08 AM, Walter Bright wrote: If expr represents a tuple, we (Andrei and I) were thinking about the syntax: auto (a, b, c, d) = expr; being equivalent to: auto t = expr; auto a = t[0]; auto b = t[1]; auto c = t[2 .. $]; You can also do this with arrays, such that: float[3] xyz

Re: Tuple assignment

2010-10-07 Thread Pelle
On 10/07/2010 09:03 AM, Walter Bright wrote: Russel Winder wrote: Python may be the best base to compare things to as tuple assignment has been in there for years. Too segue this into the previous thread, how does Python treat (1)? Is it a floor wax or a dessert topping? http://www.nbc.com/sa

Re: Partial return type specification

2010-10-04 Thread Pelle
On 10/04/2010 01:33 PM, bearophile wrote: Daniel Murphy: Maybe typeof(return) is what you're looking for? * auto foo() { return map!("a * a")([1, 2, 3, 4]); static assert(is(Unqual!(ForeachType!(typeof(return))) == int)); } * Not tested, I don't know if it works like this at all.

Re: tolf and detab

2010-10-01 Thread Pelle
On 10/01/2010 01:54 PM, bearophile wrote: Bruno Medeiros: From my understanding, Scala is a "scalable language" in the sense that it easy to add new language features, or something similar to that. I see. You may be right. But I'm missing your point here, what does Ada have to do with thi

Re: sorting hidden data.

2010-09-29 Thread Pelle
On 09/29/2010 07:10 PM, Steven Schveighoffer wrote: On Wed, 29 Sep 2010 12:26:39 -0400, Andrei Alexandrescu wrote: On 9/29/10 6:22 PDT, Steven Schveighoffer wrote: std.algorithm.sort seems to require lvalue access to elements of a range, presumably so it can call swap on two elements during s

Re: [typing] Type-erasure re generics

2010-09-29 Thread Pelle
On 09/29/2010 05:53 PM, Jesse Phillips wrote: The only benefit, which should be solve in another manner is having this code work: class A {} class B:A {} class Container(T) {} void main() { Container!(A) a = new Container!(B)(); } Sorry for falling off topic, but that code shouldn't wo

Re: A summary of D's design principles

2010-09-29 Thread Pelle
On 09/29/2010 01:22 PM, retard wrote: Wed, 29 Sep 2010 07:00:33 -0400, Steven Schveighoffer wrote: On Tue, 28 Sep 2010 17:38:43 -0400, retard wrote: Tue, 28 Sep 2010 16:20:27 -0400, Steven Schveighoffer wrote: Does C# have access to inline assembler? Agreed, it doesn't provide many new high

Re: Switch implementation

2010-09-28 Thread Pelle
On 09/28/2010 07:33 PM, bearophile wrote: Through Reddit I have found a small article about reverse engineering the switch statement: http://www.codeproject.com/KB/cpp/switch.aspx I have compiled a test program with GCC and then with DMD with minimal changes, this is the D program and the asm

Re: Proposal: Relax rules for 'pure'

2010-09-22 Thread Pelle
On 09/22/2010 10:13 AM, Don wrote: Don wrote: The docs currently state that: PROPOSAL: Drop the first requirement. Only one requirement is necessary: A pure function does not read or write any global mutable state. Wow. It seems that not one person who has responded so far has understood

Re: Random string samples & unicode - Reprise

2010-09-13 Thread Pelle
On 09/13/2010 02:09 AM, bearophile wrote: Andrei Alexandrescu: This goes into "bearophile's odd posts coming now and then". I assume you have missed most of the things I was trying to say, maybe you have not even read the original post. So I try to explain better a subset of the things I hav

Re: Assigning map result, and in-place map

2010-09-03 Thread Pelle
On 09/03/2010 12:32 PM, Bert van Leeuwen wrote: Pelle Wrote: On 09/03/2010 11:42 AM, Bert van Leeuwen wrote: 2) Related to above, I want to do something like map, but not return a new array, I want to modify elements in-place in the array. How do I do that? (without explicitly iterating

Re: Assigning map result, and in-place map

2010-09-03 Thread Pelle
On 09/03/2010 11:42 AM, Bert van Leeuwen wrote: 2) Related to above, I want to do something like map, but not return a new array, I want to modify elements in-place in the array. How do I do that? (without explicitly iterating with foreach etc.) I don't know if this is intended to be support

Re: [Challenge] implementing the ambiguous operator in D

2010-09-01 Thread Pelle
On 09/01/2010 11:49 PM, Peter Alexander wrote: On 1/09/10 9:08 PM, Philippe Sigaud wrote: Peter, can we discuss your solution here? Sure, I'd be interested to hear any improvements. Like I said in my answer, I'm still learning D so I'm sure there's many issues. For example, I made no attempt f

Re: Generic code: @autoconst, @autopure, @autonothrow

2010-08-29 Thread Pelle
On 08/29/2010 06:42 AM, Rainer Deyke wrote: On 8/28/2010 22:33, dsimcha wrote: 2. The modifiers are part of a contract and part of the public API. What if some function just happens to be pure now, but you consider that an implementation detail, not part of its specification? Client code may

Re: Using glog's design for Phobos?

2010-08-27 Thread Pelle
On 08/27/2010 03:49 PM, Steven Schveighoffer wrote: On Thu, 26 Aug 2010 18:19:24 -0400, Tomek Sowiński wrote: Dnia 26-08-2010 o 05:59:19 Andrei Alexandrescu napisał(a): At my workplace we're using Google's logging library glog (http://google-glog.googlecode.com/svn/trunk/doc/glog.html), and

Re: Why all the D hate?

2010-08-24 Thread Pelle
On 08/24/2010 02:14 PM, igabrieL wrote: - GDB developers refsue to apply up to date D patches - the language shootout included ALL other relevant languages, but hated D. This is very bad - D wiki had CSS style competition but someone wanted to keep the boring looking style. Wiki has sometimes a

Re: Unused variables, better as error or warning?

2010-08-21 Thread Pelle
On 08/20/2010 08:53 PM, Jonathan M Davis wrote: On Friday, August 20, 2010 11:35:48 Nick Sabalausky wrote: "bearophile" wrote in message news:i4luk9$2rd...@digitalmars.com... A small Reddit thread regarding if unused variables and imports are better as errors or warnings: http://www.reddit.c

Re: map on fixed-size arrays

2010-08-21 Thread Pelle
On 08/21/2010 12:37 PM, Eduardo Cavazos wrote: Hello, The 'map' from std.algorithm doesn't seem to work with fixed-size arrays: -- import std.stdio ; import std.math ; import std.algorithm ; T sq ( T ) ( T x ) { return x*x ; }

Re: Why foreach(c; someString) must yield dchar

2010-08-19 Thread Pelle
On 08/19/2010 04:37 AM, dsimcha wrote: I've been hacking in Phobos and parallelfuture and I've come to the conclusion that having typeof(c) in the expression foreach(c; string.init) not be a dchar is simply ridiculous. I don't care how much existing code gets broken, this needs to be fixed. Oth

Re: The Status of Const

2010-08-17 Thread Pelle
On 08/17/2010 02:48 PM, Steven Schveighoffer wrote: On Tue, 17 Aug 2010 06:05:55 -0400, Pelle wrote: On 08/17/2010 01:44 AM, Steven Schveighoffer wrote: On Mon, 16 Aug 2010 19:06:56 -0400, Simen kjaeraas wrote: Uhm, it works in D: class C {} class D : C {} void main( ) { D[] a; C[] b = a

Re: The Status of Const

2010-08-17 Thread Pelle
On 08/17/2010 01:44 AM, Steven Schveighoffer wrote: On Mon, 16 Aug 2010 19:06:56 -0400, Simen kjaeraas wrote: Uhm, it works in D: class C {} class D : C {} void main( ) { D[] a; C[] b = a; } Yes, I was about to say that except that is a bug kind of. The type system should only allow casting

Re: Is there a report for performance compared with popular languarge?

2010-08-12 Thread Pelle
On 08/12/2010 05:26 AM, cglee wrote: Hi, I have used 'C' and 'jav'a for several years. When I need speed, I used 'C'. When I have to reduce implemetation time, I used 'java'. In my view, D language has both merits from 'C' and 'java'. It means that it is OOP, but it generates native binary witho

Re: Congratulations to Philippe Sigaud

2010-08-05 Thread Pelle
On 08/06/2010 12:33 AM, Andrei Alexandrescu wrote: Hi everyone, I'm very excited to announce that Philippe's excellent work on dranges and his display of overall expertise earned him the well-deserved right to commit to Phobos (after checking with me, greenhorn :o)). Philippe, you're the fiftee

Re: Andrei's Google Talk

2010-08-05 Thread Pelle
On 08/05/2010 05:34 PM, dsimcha wrote: == Quote from BCS (n...@anon.com)'s article A possibly better solution would be to use an error handling strategy approach, Have the called function throw and exception supplied by the calling function. I wouldn't use this, at least without a sane defau

Re: Bugs in template constraints

2010-08-03 Thread Pelle
On 08/03/2010 11:07 PM, Andrej Mitrovic wrote: On Tue, Aug 3, 2010 at 10:23 PM, Philippe Sigaud mailto:philippe.sig...@gmail.com>> wrote: On Tue, Aug 3, 2010 at 22:04, Andrej Mitrovic mailto:andrej.mitrov...@gmail.com>> wrote: Oh and there's a shorter way to write this examp

Re: Andrei's Google Talk

2010-08-03 Thread Pelle
On 08/03/2010 06:04 PM, BCS wrote: The video is up: http://www.youtube.com/watch?v=RlVpPstLPEc On reddit: http://www.reddit.com/r/programming/comments/cx09f/google_tech_talk_andrei_alexandrescu_three_cool/ Good talk, Andrei!

Re: std.concurrency and efficient returns

2010-08-01 Thread Pelle
On 08/01/2010 09:28 PM, awishformore wrote: On 01/08/2010 21:25, awishformore wrote: On 01/08/2010 19:17, dsimcha wrote: == Quote from Jonathan M Davis (jmdavisp...@gmail.com)'s article Okay. From what I can tell, it seems to be a recurring pattern with threads that it's useful to spawn a thre

Re: What functions could be added to std.algorithm?

2010-08-01 Thread Pelle
On 08/01/2010 05:25 PM, Adam Ruppe wrote: On 8/1/10, Tomek Sowiński wrote: Link, please. ;) http://dpldocs.info If any tried to use it last week, you would have noticed it was down: my motherboard died, and the parts to fix it didn't arrive until Friday. It should be up most the time now. Y

Re: indexOf's return val upon not found

2010-07-29 Thread Pelle
On 07/29/2010 07:05 AM, Nick Sabalausky wrote: "Nick Sabalausky" wrote in message news:i2r1nt$1eg...@digitalmars.com... Wouldn't it be better if std.string's indexOf/lastIndexOf returned haystack.length instead of -1 to indicate "not found"? The -1 is never really useful, but needs like this ar

Re: Should alias expand visibility?

2010-07-27 Thread Pelle
On 07/27/2010 08:30 PM, Tomek Sowiński wrote: Pelle wrote: On 07/26/2010 12:23 AM, Tomek Sowiński wrote: If foo is private but its public alias poo exists, should you be able to use poo? (currently you can't) Tomek I think you should, because of this: private import package;

Re: Should alias expand visibility?

2010-07-27 Thread Pelle
On 07/26/2010 12:23 AM, Tomek Sowiński wrote: If foo is private but its public alias poo exists, should you be able to use poo? (currently you can't) Tomek I think you should, because of this: private import package; alias package.function myFun; If you want to provide a function from a pa

Re: @property

2010-06-25 Thread Pelle
On 06/25/2010 03:00 AM, Robert Jacques wrote: writeln = 13; doesn't compile, just so you know. ;) Then something has probably changed :) writeln!int = 13 compiles, however. And printf = "123\n", and so on.

Re: @property

2010-06-24 Thread Pelle
On 06/24/2010 11:38 PM, Steven Schveighoffer wrote: This is why you are confused -- @property *is* a naming issue. The difference between the hackish D current syntax and the sane @property syntax is that in hackish D, the caller gets to decide how to name the function, which doesn't make any sen

Re: @property

2010-06-24 Thread Pelle
On 06/24/2010 10:43 PM, Jonathan M Davis wrote: Other than legacy, code I see _0_ benefit to allowing non-property functions to be called as if they were properties. They aren't properties and shouldn't be treated that way. Now, a programmer is free to use @property as they please in the code and

Re: @property

2010-06-24 Thread Pelle
On 06/24/2010 10:45 PM, Steven Schveighoffer wrote: How is this confusing? It's a read-only property. They are used in countless design patterns. The confusion isn't their existence, but rather deciding what is a property and what is not. Furthermore, how will allowing any no-arg function

Re: @property

2010-06-24 Thread Pelle
On 06/24/2010 10:25 PM, Jonathan M Davis wrote: Pelle wrote: As heard around these parts, a lot of people want property-style function calls to require the function to be declared with @property, like this: @property foo(); //getter @property foo(int); //setter foo; //getter foo = 13

@property

2010-06-24 Thread Pelle
As heard around these parts, a lot of people want property-style function calls to require the function to be declared with @property, like this: @property foo(); //getter @property foo(int); //setter foo; //getter foo = 13; //setter While this seems quite reasonable, in practice I and others

Re: Signed word lengths and indexes

2010-06-15 Thread Pelle
On 06/15/2010 04:12 PM, Lars T. Kyllingstad wrote: On Tue, 15 Jun 2010 16:05:08 +0200, Pelle wrote: On 06/15/2010 03:25 PM, Adam Ruppe wrote: On 6/15/10, Pelle wrote: for (uint i = end - 1; i< uint.max; --i) Same functionality, really clever. That's wrong rather than cleve

Re: Signed word lengths and indexes

2010-06-15 Thread Pelle
On 06/15/2010 03:25 PM, Adam Ruppe wrote: On 6/15/10, Pelle wrote: for (uint i = end - 1; i< uint.max; --i) Same functionality, really clever. That's wrong rather than clever though. for(i< length) is saying "continue as long as you are inside the array's bounds&qu

Re: Signed word lengths and indexes

2010-06-15 Thread Pelle
On 06/15/2010 02:10 PM, Steven Schveighoffer wrote: On Tue, 15 Jun 2010 07:30:52 -0400, bearophile wrote: Steven Schveighoffer: i is unsigned, and therefore can never be less than 0. It's actually a clever way to do it that I've never thought of. Clever code is bad. It must be minimized. In

Re: Signed word lengths and indexes

2010-06-15 Thread Pelle
On 06/15/2010 03:49 AM, Walter Bright wrote: Here's what the wikipedia said about it. "In Python, a number that becomes too large for an integer seamlessly becomes a long.[1] And in Python 3.0, integers and arbitrary sized longs are unified." -- http://en.wikipedia.org/wiki/Integer_overflow (J

Re: Go Programming talk [OT]

2010-06-09 Thread Pelle
On 06/09/2010 01:04 AM, Leandro Lucarella wrote: Bane, el 8 de junio a las 14:42 me escribiste: Is a trade-off. When you don't handle the errors, exceptions might be a win, but when you do handle them, I'm not so sure. And again, I'm not saying I particularly like one more than the other, I don

Re: Wide characters support in D

2010-06-08 Thread Pelle
On 06/08/2010 08:20 PM, Ruslan Nikolaev wrote: No. New messages are definitely not created by me. You can verify it here: http://blog.gmane.org/gmane.comp.lang.d.general You can easily see that in none of the top posts (except for the first one) my name appears first. In fact, you have just cre

Re: If you have to learn just one programming language

2010-05-31 Thread Pelle
On 05/31/2010 08:17 PM, retard wrote: But way better than in java, C, C++ or almost any other language. So basically if I'm offering you $10 and $10, you're taking $10 because it's more than $1 or $2 or any value between $3 and $4. Great logic. D has a delegate syntax which fits with the

Re: If you have to learn just one programming language

2010-05-31 Thread Pelle
On 05/31/2010 05:43 PM, retard wrote: D is very close to C. The productivity is much lower than with other modern scripting or hybrid-functional languages. I disagree, unless you need a specific library which D does not yet have. DMD is much slower than Sun Javac/Jvm 7, GNU GCC 4.5, and LLVM.

Re: Array access via pointer

2010-05-30 Thread Pelle
On 05/30/2010 11:54 PM, Robert wrote: On 2010-05-30 23:12:06 +0200, "Simen kjaeraas" said: Going again with the C code: typedef struct array { int* data; int length; }; You would use an array like this: void foo( ) { array arr; arr.ptr = malloc(32); arr.length = 8; } Now, as you can probbl

Re: Array access via pointer

2010-05-30 Thread Pelle
On 05/30/2010 11:00 PM, Robert wrote: On 2010-05-30 22:16:55 +0200, Pelle said: &data[0] and &data are very different things, if you have a dynamic array. Yes, that's what I found out too. What's the exact difference? A dynamic array is a fat pointer with a length, appr

Re: Array access via pointer

2010-05-30 Thread Pelle
On 05/30/2010 09:43 PM, Robert wrote: Hi, I hope some of you D gurus can help me getting my mind setup correct when using D arrays. I have an array: data[1 .. 2048] of type ubyte I'm interested in getting the addresse of the array and its data members. So I used: writefln("adress data[%d] = %d

Re: The last changes to range

2010-05-30 Thread Pelle
On 05/30/2010 12:11 PM, Philippe Sigaud wrote: On Sat, May 29, 2010 at 23:30, Andrei Alexandrescu mailto:seewebsiteforem...@erdani.org>> wrote: On 05/29/2010 03:05 PM, Philippe Sigaud wrote: Does that mean that you changed some other parts recently? Not recently, I think I ma

Re: AAs of struct or array

2010-05-27 Thread Pelle
On 05/27/2010 02:33 PM, bearophile wrote: I have noticed a significant speed difference between foo1 and foo2 (D2 code): import std.c.stdio: printf; int foo1(int x, int y) { static int[int[2]] cache; int[2] args = [x, y]; cache[args] = x; return x; } int foo2(int x, int y)

Re: container stuff

2010-05-26 Thread Pelle
On 05/26/2010 11:44 AM, bearophile wrote: Andrei A.: I hope to work with ranges only.< Programming life is complex, you can't fit all of it in one schema ("A foolish consistency is the hobgoblin of little minds"). Couldn't you just define opApply where you need it and it will be used whe

Re: To use opDispatch

2010-05-24 Thread Pelle
On 05/23/2010 09:17 PM, BCS wrote: template If(bool b, T, F) { static if(b) alias T If; else alias F If; } That's in phobos, :) http://digitalmars.com/d/2.0/phobos/std_traits.html#Select

Re: Poll: Primary D version

2010-05-23 Thread Pelle
On 05/23/2010 09:39 AM, Walter Bright wrote: Oh, I forgot to mention. Back in the 16 bit days, I invented something called a "handle pointer". http://www.digitalmars.com/ctg/handle-pointers.html "You must be sure your program frees memory when it exits; otherwise, it will be unavailable to ot

Re: Poll: Primary D version

2010-05-23 Thread Pelle
On 05/23/2010 10:14 AM, Mike Parker wrote: And I would argue that it's unreasonable to expect the declarations of C functions to be declared const-correct based on their usage. To my knowledge, all of the C bindings for D to date either don't use const at all (because they were created for D1) or

Re: Poll: Primary D version

2010-05-22 Thread Pelle
On 05/22/2010 08:26 PM, Robert Clipsham wrote: extern(C)void someFunc(char*); There is no function in phobos which will allow me to call this function using a D string You could use (array.dup ~ '\0').ptr, right? extern(C)void someFunc(wchar*); This is impossible with phobos, there's no fun

Re: std.gregorian contribution

2010-05-17 Thread Pelle
On 05/17/2010 08:00 PM, Simen kjaeraas wrote: D could use a set type, and this is a very nice way to specify these different parameters. votes = -~votes; I agree, and I find a set type to be generally very useful. :)

  1   2   3   >