Re: division of objects into classes and structures is bad

2009-01-06 Thread Weed
Weed пишет: > Bill Baxter пишет: >> On Tue, Jan 6, 2009 at 1:41 PM, Christopher Wright >> wrote: >>> Weed wrote: Who agrees with me? There are still ideas as it is possible to solve this problem and not to destroy language? >>> When you reply to your reply to your reply to your post and

Re: Portability of uint over/underflow behavior

2009-01-06 Thread Don
Nick Sabalausky wrote: "Don" wrote in message news:gjt7cb$1j...@digitalmars.com... Nick Sabalausky wrote: "Don" wrote in message news:gjsnf2$26g...@digitalmars.com... bearophile wrote: Don: The question was about incrementing uint, not int. Preventing wraparound on uints would break everyt

Re: foreach ... else statement

2009-01-06 Thread Brian
On Mon, 05 Jan 2009 11:13:49 +0100, grauzone wrote: > void somefunction() { > do_stuff(); > if (error) > goto error_exit: > do_more_stuff(); > > return; > > error_exit: > handle_error(); > } > > This could be replaced by something like this: > > void

Re: foreach ... else statement

2009-01-06 Thread Daniel Keep
Brian wrote: [snip] neither of those seem necessary in that example, whats wrong with this: void somefunction() { do_stuff(); if (error) handle_error(); else do_more_stuff(); } A few things I can think of: 1. You're mixing error handli

Arrays pass

2009-01-06 Thread bearophile
This may be a topic already discussed a lot in the past, if so please bear with me, it may take me years to catch most of the things already discussed. I think the way to pass a built-in array may have few main usages: 1) read/write the array, but the length and ptr can't change (default in D1)

Off subject

2009-01-06 Thread Vincent Richomme
Hi, sorry to ask my question here but since people are motivated by new language, source code, ... I thought it was a good place to ask my question about source code analysis. I would like to know if there are some parsers/scripts that could parse some C/C++ language and that could insert prin

Re: Off subject

2009-01-06 Thread Ary Borenszweig
Vincent Richomme wrote: Hi, sorry to ask my question here but since people are motivated by new language, source code, ... I thought it was a good place to ask my question about source code analysis. I would like to know if there are some parsers/scripts that could parse some C/C++ language a

Question about associative arrays

2009-01-06 Thread Tim M
Do the associative arrays work using the real key or a hash of it and if it's a hash then what does it do to prevent hash collisions.

Re: Question about associative arrays

2009-01-06 Thread dsimcha
== Quote from Tim M (a...@b.com)'s article > Do the associative arrays work using the real key or a hash of it and if > it's a hash then what does it do to prevent hash collisions. The builtin AAs in DMD are implemented as hash tables, although IIRC this is not guaranteed by the spec and other imp

Re: Randomness in built-in .sort

2009-01-06 Thread Walter Bright
Bill Baxter wrote: It seems to me that the built-in .sort uses a randomized algorithm that leads to results that differ from run-to-run when there are elements with identical keys. No, it doesn't use random sorts. The source code is included, so this should be easy to verify.

Re: 'naked' keyword

2009-01-06 Thread Tomas Lindquist Olsen
On Fri, Jan 2, 2009 at 9:21 AM, Don wrote: > Duane Bailey wrote: > >> I am currently porting LDC to PowerPC and, hopefully, eventually the >> POWER and CELL platforms as well. The first bit requires me to port the >> inline assembler, allowing me to >> > review the problems that the D language p

Re: Randomness in built-in .sort

2009-01-06 Thread Sean Kelly
== Quote from Walter Bright (newshou...@digitalmars.com)'s article > Bill Baxter wrote: > > It seems to me that the built-in .sort uses a randomized algorithm > > that leads to results that differ from run-to-run when there are > > elements with identical keys. > No, it doesn't use random sorts. Th

Re: Randomness in built-in .sort

2009-01-06 Thread Walter Bright
Ary Borenszweig wrote: I think Bill speaks about a stable sort. You can have an unstable sort algorithm without having explicity a random invocation. Note that he's saying "leads to results that differ from run-to-run when there are elements with identical keys". And I believe that the sort i

Re: Randomness in built-in .sort

2009-01-06 Thread Ary Borenszweig
Sean Kelly wrote: == Quote from Walter Bright (newshou...@digitalmars.com)'s article Bill Baxter wrote: It seems to me that the built-in .sort uses a randomized algorithm that leads to results that differ from run-to-run when there are elements with identical keys. No, it doesn't use random so

new principle of division between structures and classes

2009-01-06 Thread Weed
(Here I generalise my sentence with supplement) The POD data and the data supporting polymorphism are necessary to us. POD the data is stored in structs and polymorphic objects is classes. Both types (class and struct) can be instanced in a heap or on a stack. (And in invariant ROM too, but ther

Re: Randomness in built-in .sort

2009-01-06 Thread Bill Baxter
On Wed, Jan 7, 2009 at 4:09 AM, Walter Bright wrote: > Ary Borenszweig wrote: >> >> I think Bill speaks about a stable sort. You can have an unstable sort >> algorithm without having explicity a random invocation. Note that he's >> saying "leads to results that differ from run-to-run when there ar

Re: Possible D2 solution to the upcasting array problem, and a related problem with const and nested arrays

2009-01-06 Thread Stewart Gordon
Stewart Gordon wrote: These unsafe conversions could still be allowed by explicit casts, should they be needed for something, IWC you'd be expected to know what you're doing. Just thinking about it, I wonder if this would be a good time to reconsider Janice's 1⅓-year-old proposal for preven

Re: Possible D2 solution to the upcasting array problem, and a related problem with const and nested arrays

2009-01-06 Thread Denis Koroskin
On Wed, 07 Jan 2009 03:49:38 +0300, Stewart Gordon wrote: Stewart Gordon wrote: These unsafe conversions could still be allowed by explicit casts, should they be needed for something, IWC you'd be expected to know what you're doing. Just thinking about it, I wonder if this would be a go

Re: Possible D2 solution to the upcasting array problem, and a related problem with const and nested arrays

2009-01-06 Thread Stewart Gordon
Denis Koroskin wrote: Nice, but I don't like the proposed syntax much, especially these: cast(!const BaseClass[]) cast(!const const(int)[][]) I believe it would be better to split them into two separate casts as follows: BaseClass[] base = cast(BaseClass[])cast(!const)derived; Won't work.

Re: foreach ... else statement

2009-01-06 Thread Robert Fraser
Daniel Keep Wrote: > It's rather ironic, but one thing that struck me going from Visual Basic > to Python was that VB had much nicer error handling; instead of having > error handling all over the place, it was all localised to the end of > the function. This is why I absolutely adore scope sta

Re: foreach ... else statement

2009-01-06 Thread Walter Bright
grauzone wrote: bearophile wrote: Don: Actually Walter loves goto, so DMD copes really well with it. When possible it's better to use structured programming and avoid gotos. That construct can avoid gotos in some common situations. And regarding the compiler back-end, I think it's also bette

Re: foreach ... else statement

2009-01-06 Thread Walter Bright
Don wrote: It's possible to create grotesque configurations of 'goto' which are extremely difficult to analyze. For a human, yes. For well-known optimization algorithms, no.

Re: foreach ... else statement

2009-01-06 Thread Walter Bright
Don wrote: I still avoid goto because I was told to. But eventually I realised that it's 100% propaganda. I actually think my code would be cleaner if I used it; it would allow lots of local flag variables to be eliminated. But I still have this residual prejudice against 'goto' which is really

Re: foreach ... else statement

2009-01-06 Thread Andrei Alexandrescu
Walter Bright wrote: grauzone wrote: bearophile wrote: Don: Actually Walter loves goto, so DMD copes really well with it. When possible it's better to use structured programming and avoid gotos. That construct can avoid gotos in some common situations. And regarding the compiler back-end, I

Re: Off subject

2009-01-06 Thread Jussi Jumppanen
Vincent Richomme Wrote: > I would like to know if there are some parsers/scripts that could parse > some C/C++ language and that could insert printf in each function. One option would be to use a regular expression within a search and replace. Just as a simple test I came up regexp that does s

Re: foreach ... else statement

2009-01-06 Thread Walter Bright
Andrei Alexandrescu wrote: The challenge the paper addresses is constructing the SSA form in one shot. There are indeed algorithms that build the SSA in several passes. My vague recollection from a compiler construction class is that there are a number of static analyses that need to do a fixe

Re: foreach ... else statement

2009-01-06 Thread Benji Smith
Walter Bright wrote: I keep thinking I should put on a "Compiler Construction" seminar! Sign me up!

Re: foreach ... else statement

2009-01-06 Thread BCS
Reply to Walter, I keep thinking I should put on a "Compiler Construction" seminar! That would be fun. If I could, I'd show up.