Re: This just in: authorless TDPL becomes collector's edition

2010-06-22 Thread Mike James
Adrian Matoga e...@atari8.info wrote in message 
news:hvorrg$j3...@digitalmars.com...

Alix Pexton pisze:

On 21/06/2010 20:23, Mike James wrote:
Got my collectors item  delivered today from Amazon UK. Looks good. I 
like

the bonus of being able to download a PDF version of TDPL.


Where to find this PDF version? I can only see the contents, excerpt from 
first chapter, and the index. And I can't stand waiting for my paper copy 
in its long way to PL.


When you get the book it has an access code to download the PDF book from 
Safari. But you need the book first :-)


-=mike=- 



Re: This just in: authorless TDPL becomes collector's edition

2010-06-22 Thread Patrick Byrne

On 22/06/2010 10:03, Mike James wrote:


When you get the book it has an access code to download the PDF book
from Safari. But you need the book first :-)


Can you actually download the pdf? All I can see is the interactive browser - It is quite nice to use but I would much rather have a 
pdf file to take home with me, at the end of the day.




Re: This just in: authorless TDPL becomes collector's edition

2010-06-22 Thread Mike James
Patrick Byrne pby...@frontier.co.uk wrote in message 
news:hvq1dr$30e...@digitalmars.com...

On 22/06/2010 10:03, Mike James wrote:


When you get the book it has an access code to download the PDF book
from Safari. But you need the book first :-)


Can you actually download the pdf? All I can see is the interactive 
browser - It is quite nice to use but I would much rather have a pdf file 
to take home with me, at the end of the day.




Yes you can download the PDF. If you look at the last page of TDPL there is 
instructions. Basically you request a PDF and the PDF is generated with your 
name and email address as a footer on each page. Safari then emails you the 
webpage you can download it from. You just need to signup for the trial 
period.


-=mike=- 



Re: This just in: authorless TDPL becomes collector's edition

2010-06-22 Thread Patrick Byrne

On 22/06/2010 11:44, Mike James wrote:

Patrick Byrne pby...@frontier.co.uk wrote in message
news:hvq1dr$30e...@digitalmars.com...

On 22/06/2010 10:03, Mike James wrote:


When you get the book it has an access code to download the PDF book
from Safari. But you need the book first :-)


Can you actually download the pdf? All I can see is the interactive
browser - It is quite nice to use but I would much rather have a pdf
file to take home with me, at the end of the day.



Yes you can download the PDF. If you look at the last page of TDPL there
is instructions. Basically you request a PDF and the PDF is generated
with your name and email address as a footer on each page. Safari then
emails you the webpage you can download it from. You just need to signup
for the trial period.

-=mike=-


Yes I got there in the end - thanks.



Re: This just in: authorless TDPL becomes collector's edition

2010-06-22 Thread Jacob Carlborg

On 2010-06-21 21:23, Mike James wrote:

Got my collectors item  delivered today from Amazon UK. Looks good. I like
the bonus of being able to download a PDF version of TDPL.

Thanks for all the hard work Andrei.

-=mike=-

Andrei Alexandrescuseewebsiteforem...@erdani.org  wrote in message
news:hu3hq6$2f0...@digitalmars.com...

Due to a pretty odd mistake at the printer, the first 1000 copies of TDPL
will not have the name of the author on their cover. (The name still
appears on the back cover and the spine.)

The history of printing is rife with rare printing mistakes that have
become collector's editions. Preorder now to be among the first 1000
readers who get the authorless TDPL edition.


Andrei


What happened to the nice looking PDF file we saw previews on, that one 
with syntax highlighting and a green background in the code example?



--
/Jacob Carlborg


Re: This just in: authorless TDPL becomes collector's edition

2010-06-22 Thread Andrei Alexandrescu

On 06/22/2010 07:45 AM, Jacob Carlborg wrote:

On 2010-06-21 21:23, Mike James wrote:

Got my collectors item delivered today from Amazon UK. Looks good. I
like
the bonus of being able to download a PDF version of TDPL.

Thanks for all the hard work Andrei.

-=mike=-

Andrei Alexandrescuseewebsiteforem...@erdani.org wrote in message
news:hu3hq6$2f0...@digitalmars.com...

Due to a pretty odd mistake at the printer, the first 1000 copies of
TDPL
will not have the name of the author on their cover. (The name still
appears on the back cover and the spine.)

The history of printing is rife with rare printing mistakes that have
become collector's editions. Preorder now to be among the first 1000
readers who get the authorless TDPL edition.


Andrei


What happened to the nice looking PDF file we saw previews on, that one
with syntax highlighting and a green background in the code example?


That's the iPad edition :o).

Now seriously, what happens is that what you see is exactly what went to 
the printer. I can configure colors for a color edition, but for now the 
publisher asked me for black and white.


Andrei


Re: This just in: authorless TDPL becomes collector's edition

2010-06-22 Thread Lutger
Andrei Alexandrescu wrote:

 Due to a pretty odd mistake at the printer, the first 1000 copies of
 TDPL will not have the name of the author on their cover. (The name
 still appears on the back cover and the spine.)
 
 The history of printing is rife with rare printing mistakes that have
 become collector's editions. Preorder now to be among the first 1000
 readers who get the authorless TDPL edition.
 
 
 Andrei

Just got my authorless copy from the local bookstore, they have several more of 
those in stock at their little C++ corner :) I'm looking forward to reading it. 
 


Re: This just in: authorless TDPL becomes collector's edition

2010-06-22 Thread Jacob Carlborg

On 2010-06-22 14:51, Andrei Alexandrescu wrote:

On 06/22/2010 07:45 AM, Jacob Carlborg wrote:

On 2010-06-21 21:23, Mike James wrote:

Got my collectors item delivered today from Amazon UK. Looks good. I
like
the bonus of being able to download a PDF version of TDPL.

Thanks for all the hard work Andrei.

-=mike=-

Andrei Alexandrescuseewebsiteforem...@erdani.org wrote in message
news:hu3hq6$2f0...@digitalmars.com...

Due to a pretty odd mistake at the printer, the first 1000 copies of
TDPL
will not have the name of the author on their cover. (The name still
appears on the back cover and the spine.)

The history of printing is rife with rare printing mistakes that have
become collector's editions. Preorder now to be among the first 1000
readers who get the authorless TDPL edition.


Andrei


What happened to the nice looking PDF file we saw previews on, that one
with syntax highlighting and a green background in the code example?


That's the iPad edition :o).

Now seriously, what happens is that what you see is exactly what went to
the printer. I can configure colors for a color edition, but for now the
publisher asked me for black and white.

Andrei


That's too bad. I can understand that the publisher want it in black and 
withe but the PDF, it would have been nice to the PDF in color.


--
/Jacob Carlborg


Re: This just in: authorless TDPL becomes collector's edition

2010-06-22 Thread Mike James
Jacob Carlborg d...@me.com wrote in message 
news:hvr503$287...@digitalmars.com...
 On 2010-06-22 14:51, Andrei Alexandrescu wrote:
 On 06/22/2010 07:45 AM, Jacob Carlborg wrote:
 On 2010-06-21 21:23, Mike James wrote:
 Got my collectors item delivered today from Amazon UK. Looks good. I
 like
 the bonus of being able to download a PDF version of TDPL.

 Thanks for all the hard work Andrei.

 -=mike=-

 Andrei Alexandrescuseewebsiteforem...@erdani.org wrote in message
 news:hu3hq6$2f0...@digitalmars.com...
 Due to a pretty odd mistake at the printer, the first 1000 copies of
 TDPL
 will not have the name of the author on their cover. (The name still
 appears on the back cover and the spine.)

 The history of printing is rife with rare printing mistakes that have
 become collector's editions. Preorder now to be among the first 1000
 readers who get the authorless TDPL edition.


 Andrei

 What happened to the nice looking PDF file we saw previews on, that one
 with syntax highlighting and a green background in the code example?

 That's the iPad edition :o).

 Now seriously, what happens is that what you see is exactly what went to
 the printer. I can configure colors for a color edition, but for now the
 publisher asked me for black and white.

 Andrei

 That's too bad. I can understand that the publisher want it in black and 
 withe but the PDF, it would have been nice to the PDF in color.

 -- 
 /Jacob Carlborg

Maybe the color PDF will be another collectors item ;-)

-=mike=-




Re: finding a circular dependency

2010-06-22 Thread Rory McGuire
On Mon, 21 Jun 2010 20:51:01 +0200, Steven Schveighoffer  
schvei...@yahoo.com wrote:


I've been trying to get a modified version of std.process to compile  
(with Lars K's changes) for windows, and phobos finally compiled.


So I built a little test program, compiled it, and I get the following  
error message:


object.Exception: circular dependency in module std.stdio.

Great.  How did that happen?  Being that I didn't write std.stdio, only  
modified it slightly (and certainly didn't change any imports), I  
haven't the foggiest where this problem is.  Given that the runtime can  
prove there is a circular dependency, and apparently knows the names of  
the modules, how about showing me the cycle?


:P

I do not look forward to tracking this one down...

-Steve


doesn't -verbose list the modules dmd is importing? Perhaps it stops at  
the offending module?


Re: Floating point not loaded

2010-06-22 Thread Clemens
Clemens Wrote:

 I have a stupid problem linking D with C. This is with D 1.062, haven't tried 
 D2. So say I have two files:
 
 -- cfmt.c 
 
 #include string.h
 
 char* myfmt(double x)
 {
   static char buf[40];
   sprintf(buf, %f, x);
   return buf;
 }
 
 --- test.d 
 
 extern(C) char* myfmt(double x);
 
 void main()
 {
   myfmt(42.3);
 }
 
 ---
 
 and I compile and link them as follows:
 
  dmc -c cfmt.c
  dmd test.d cfmt.obj
  test.exe
 
 I get the runtime error Floating point not loaded. No exception or 
 anything, the executable just terminates with that message on the terminal. I 
 found a short paragraph about that runtime error on
 http://www.digitalmars.com/ctg/runtime.html
 but it wasn't too helpful; a quick grep showed me that _fltused occurs in 
 both cfmt.obj and test.obj.
 
 Anyone seen this before? What can I do? I'm pretty sure this used to work 
 with an older version. The actual real-world use case is linking to Lua, 
 which bombs out with the same message once you use the string concatenation 
 operator with a numeric argument. I used the Lua binding from dsource which 
 comes with a precompiled library, and just to be sure I then compiled my own 
 version of Lua with dmc; to no avail.
 
 Clemens

FWIW, I found a workaround to this: if I specify to link with snn.lib 
explicitly on the command line, then everything seems to work. I'm a bit 
surprised since I thought that snn.lib is pulled in automatically. Is this a 
bug in DMD, in Optlink, or by some strange twist of fate expected behavior?

Clemens


Re: Errors in TDPL

2010-06-22 Thread Alix Pexton

On 21/06/2010 21:51, Tomek Sowiński wrote:

Dnia 21-06-2010 o 21:57:49 Alix Pexton alix.dot.pex...@gmail.dot.com
napisał(a):


There is only one mention of lazy evaluation in the index and it
doesn't mention the lazy k/w at all. I seem to remember Andrei
dislikes it, but also that there is another way to get function params
to be evaluated lazily without using it.


Yeah, speaking of which - what happened to that proposal*?

*The proposal AFAIR was (correct me if wrong): if a function has a
parameterless delegate as a parameter, then on the call site any
expression in the delegate slot is implicitly turned into a delegate. I
think the delegate ought to be pure to make the magic happen.

Yeah, speaking of which - do/will we have pure delegates?


Tomek


This is the trick I was refering to, from a post by the programmer 
formerly known as downs...


Amusing D facts: typesafe variadic arrays are lazy!

 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 thar! );
   }

 It's true! :)

A...


Re: enforce()?

2010-06-22 Thread Walter Bright

Sean Kelly wrote:

Regarding DbC, I can't say that I've ever worked on a system where lives hung
in the balance (an admittedly extreme example of where DbC is useful),


I have, and here's how it's done:

http://www.drdobbs.com/blog/archives/2009/10/safe_systems_fr.html

http://www.drdobbs.com/blog/archives/2009/11/designing_safe.html

I really wish this was more widely known in the software engineering business. 
It's frustrating to see it relearned the hard way, over and over.


And not just the software business, I saw a technical overview of the BP oil 
spill failure, and the rig design violated just about every principle of safe 
system design.


Re: Errors in TDPL

2010-06-22 Thread Walter Bright

Andrei Alexandrescu wrote:

On 06/21/2010 08:47 PM, Jonathan M Davis wrote:
On page 82 of TDPL, it's talking about try/catch/finally statements, 
and it
says that all controlled statement must be block statements; that is 
they

must be enclosed with braces. However, dmd does not seem to require that
try/catch/finally blocks have braces, which is what I would expect that
sentence to mean. C++ has that restriction for reasons that I don't
understand, but as far as I can tell, D does not - certainly dmd doesn't
appear to require it. Is the statement correct but refers to something 
else,

or is it in error?

- Jonathan M Davis


That's a surprise to me. Walter, is that intentional?


They do not require braces, they just require that the controlling statement not 
be a single ;. In the grammar, this is a ScopeStatement, which is a 
NonEmptyStatement or a BlockStatement.



http://www.digitalmars.com/d/2.0/statement.html#ScopeStatement


Re: This just in: authorless TDPL becomes collector's edition

2010-06-22 Thread Mike James
Adrian Matoga e...@atari8.info wrote in message 
news:hvorrg$j3...@digitalmars.com...

Alix Pexton pisze:

On 21/06/2010 20:23, Mike James wrote:
Got my collectors item  delivered today from Amazon UK. Looks good. I 
like

the bonus of being able to download a PDF version of TDPL.


Where to find this PDF version? I can only see the contents, excerpt from 
first chapter, and the index. And I can't stand waiting for my paper copy 
in its long way to PL.


When you get the book it has an access code to download the PDF book from 
Safari. But you need the book first :-)


-=mike=- 



Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-22 Thread Lars T. Kyllingstad
On Mon, 21 Jun 2010 20:27:32 -0700, Bill Baxter wrote:

 On Mon, Jun 21, 2010 at 6:31 PM, Leandro Lucarella l...@llucax.com.ar
 wrote:
 Bill Baxter, el 21 de junio a las 17:13 me escribiste:
 On Mon, Jun 21, 2010 at 4:24 PM, Leandro Lucarella
 l...@llucax.com.ar wrote:
  goto next case; is a little more verbose but very clear to me :)
 
  Maybe just next case; is a shorter alternative...

 That would be great if next were a D keyword.  But I don't think
 you're going to get Walter to add a keyword just for this.

 Damn! Where did I get next from? I don't know...
 
 I think it's a keyword in Perl maybe?
 
 --bb

It is a keyword in BASIC, at least. :)

  FOR i = 1 TO 100
PRINT i
  NEXT

-Lars


Latest string_token Code

2010-06-22 Thread Ben Hanson
Hi there,

I've basically got the string_token class working now. Thanks to everyone who
helped. It still needs some work as memmove works with bytes so I need the
equivalent of 'sizeof' in D for this.

'squeeze' doesn't work with wide chars, so I will write my own version.

When I shrink or grow char arrays, I'd like to know if I should re-set my
pointers into them accordingly.

If anyone can point out any other obvious issues, bad style etc. that would be
appreciated. Please bear in mind that I'd like the code to be as fast as 
possible.

Here's the source:

Regards,

Ben

module main;

import std.algorithm;
import std.array;
import std.c.string;
import std.string;

import std.stdio;

template regex(CharT)
{
struct basic_string_token
{
bool _negated = false;
CharT[] _charset;
enum size_t MAX_CHARS = CharT.max + 1;
enum size_t START_CHAR = cast(CharT) 0x80  0 ? 0x80 : 0;

this(const bool negated_, ref CharT[] charset_)
{
_negated = negated_;
_charset = charset_;
}

void remove_duplicates()
{
_charset.sort;
_charset = squeeze(_charset.idup).dup;
}

void normalise()
{
if (_charset.length == MAX_CHARS)
{
_negated = !_negated;
_charset.clear();
}
else if (_charset.length  MAX_CHARS / 2)
{
negate();
}
}

void negate()
{
CharT curr_char_ = START_CHAR;
CharT[] temp_;
CharT *ptr_;
CharT *curr_ = _charset.ptr;
CharT *end_ = curr_ + _charset.length;
size_t i_ = 0;

_negated = !_negated;
temp_.length = MAX_CHARS - _charset.length;
ptr_ = temp_.ptr;

while (curr_  end_)
{
while (*curr_  curr_char_)
{
*ptr_ = curr_char_;
++ptr_;
++curr_char_;
++i_;
}

++curr_char_;
++curr_;
++i_;
}

for (; i_  MAX_CHARS; ++i_)
{
*ptr_ = curr_char_;
++ptr_;
++curr_char_;
}

_charset = temp_;
}

bool empty()
{
return _charset.length == 0  !_negated;
}

bool any()
{
return _charset.length == 0  _negated;
}

void clear()
{
_negated = false;
_charset.length = 0;
}

void intersect(ref basic_string_token rhs_,
ref basic_string_token overlap_)
{
if ((any()  rhs_.any()) || (_negated == rhs_._negated 
!any()  !rhs_.any()))
{
intersect_same_types(rhs_, overlap_);
}
else
{
intersect_diff_types(rhs_, overlap_);
}
}

private:
void intersect_same_types(ref basic_string_token rhs_,
ref basic_string_token overlap_)
{
if (any())
{
clear();
overlap_._negated = true;
rhs_.clear();
}
else
{
CharT *iter_ = _charset.ptr;
CharT *end_ = iter_ + _charset.length;
CharT *rhs_iter_ = rhs_._charset.ptr;
CharT *rhs_end_ = rhs_iter_ + rhs_._charset.length;

overlap_._negated = _negated;

while (iter_ != end_  rhs_iter_ != rhs_end_)
{
if (*iter_  *rhs_iter_)
{
++iter_;
}
else if (*iter_  *rhs_iter_)
{
++rhs_iter_;
}
else
{
overlap_._charset ~= *iter_;
memmove(iter_, iter_ + 1, _charset.ptr 
+ _charset.length - iter_);
--end_;
_charset.length -= 1;
memmove(rhs_iter_, rhs_iter_ + 1, 
rhs_._charset.ptr +

Feature request: Shared receive for all waitable objects

2010-06-22 Thread Phil Deets

http://d.puremagic.com/issues/show_bug.cgi?id=4365

It would be nice to be able to wait for either socket data or a  
cross-thread message. I've filed a bug with the request. I'm just posting  
here in case anyone wants to vote on the bug or in case this post will  
spur discussion which will cause the feature to be added sooner.


Thanks,
Phil Deets


Re: Latest string_token Code

2010-06-22 Thread Rory McGuire

I think sizeof is a property, e.g. char.sizeof or:

struct A {
int a;
char[10] b;
}


A.sizeof

A a;
a.sizeof

you get the picture. (Have I got it?)

-Rory



On Tue, 22 Jun 2010 12:07:37 +0200, Ben Hanson ben.han...@tfbplc.co.uk  
wrote:



Hi there,

I've basically got the string_token class working now. Thanks to  
everyone who
helped. It still needs some work as memmove works with bytes so I need  
the

equivalent of 'sizeof' in D for this.

'squeeze' doesn't work with wide chars, so I will write my own version.

When I shrink or grow char arrays, I'd like to know if I should re-set my
pointers into them accordingly.

If anyone can point out any other obvious issues, bad style etc. that  
would be
appreciated. Please bear in mind that I'd like the code to be as fast as  
possible.


Here's the source:

Regards,

Ben

module main;

import std.algorithm;
import std.array;
import std.c.string;
import std.string;

import std.stdio;

template regex(CharT)
{
struct basic_string_token
{
bool _negated = false;
CharT[] _charset;
enum size_t MAX_CHARS = CharT.max + 1;
enum size_t START_CHAR = cast(CharT) 0x80  0 ? 0x80 : 0;

this(const bool negated_, ref CharT[] charset_)
{
_negated = negated_;
_charset = charset_;
}

void remove_duplicates()
{
_charset.sort;
_charset = squeeze(_charset.idup).dup;
}

void normalise()
{
if (_charset.length == MAX_CHARS)
{
_negated = !_negated;
_charset.clear();
}
else if (_charset.length  MAX_CHARS / 2)
{
negate();
}
}

void negate()
{
CharT curr_char_ = START_CHAR;
CharT[] temp_;
CharT *ptr_;
CharT *curr_ = _charset.ptr;
CharT *end_ = curr_ + _charset.length;
size_t i_ = 0;

_negated = !_negated;
temp_.length = MAX_CHARS - _charset.length;
ptr_ = temp_.ptr;

while (curr_  end_)
{
while (*curr_  curr_char_)
{
*ptr_ = curr_char_;
++ptr_;
++curr_char_;
++i_;
}

++curr_char_;
++curr_;
++i_;
}

for (; i_  MAX_CHARS; ++i_)
{
*ptr_ = curr_char_;
++ptr_;
++curr_char_;
}

_charset = temp_;
}

bool empty()
{
return _charset.length == 0  !_negated;
}

bool any()
{
return _charset.length == 0  _negated;
}

void clear()
{
_negated = false;
_charset.length = 0;
}

void intersect(ref basic_string_token rhs_,
ref basic_string_token overlap_)
{
if ((any()  rhs_.any()) || (_negated == rhs_._negated 
!any()  !rhs_.any()))
{
intersect_same_types(rhs_, overlap_);
}
else
{
intersect_diff_types(rhs_, overlap_);
}
}

private:
void intersect_same_types(ref basic_string_token rhs_,
ref basic_string_token overlap_)
{
if (any())
{
clear();
overlap_._negated = true;
rhs_.clear();
}
else
{
CharT *iter_ = _charset.ptr;
CharT *end_ = iter_ + _charset.length;
CharT *rhs_iter_ = rhs_._charset.ptr;
CharT *rhs_end_ = rhs_iter_ + rhs_._charset.length;

overlap_._negated = _negated;

while (iter_ != end_  rhs_iter_ != rhs_end_)
{
if (*iter_  *rhs_iter_)
{
++iter_;
}
else if (*iter_  *rhs_iter_)
{
++rhs_iter_;
}
else
{
overlap_._charset ~= *iter_;
memmove(iter_, iter_ 

Re: Latest string_token Code

2010-06-22 Thread bearophile
Ben Hanson:
 It still needs some work as memmove works with bytes so I need the
 equivalent of 'sizeof' in D for this.

T.sizeof gives the size of the init of a variable of type T.
If T is a dynamic array it returns wordsSize*2, so if you need the item size 
you can write T[0].sizeof.

Why do you use so many underscores?
Bye,
bearophile


Re: DMD Backend Long-term

2010-06-22 Thread Kagamin
Robert Jacques Wrote:

 The main issue (as I understand it) is adding windows style structured  
 exception handling to LLVM.

C++ compiles for me. Or are there some other issues?


Re: finding a circular dependency

2010-06-22 Thread Steven Schveighoffer
On Tue, 22 Jun 2010 03:14:38 -0400, Rory McGuire rmcgu...@neonova.co.za  
wrote:


On Mon, 21 Jun 2010 20:51:01 +0200, Steven Schveighoffer  
schvei...@yahoo.com wrote:


I've been trying to get a modified version of std.process to compile  
(with Lars K's changes) for windows, and phobos finally compiled.


So I built a little test program, compiled it, and I get the following  
error message:


object.Exception: circular dependency in module std.stdio.

Great.  How did that happen?  Being that I didn't write std.stdio, only  
modified it slightly (and certainly didn't change any imports), I  
haven't the foggiest where this problem is.  Given that the runtime can  
prove there is a circular dependency, and apparently knows the names of  
the modules, how about showing me the cycle?


:P

I do not look forward to tracking this one down...

-Steve


doesn't -verbose list the modules dmd is importing? Perhaps it stops at  
the offending module?


It's a runtime issue, not a compiler issue.

-Steve


Re: finding a circular dependency

2010-06-22 Thread Steven Schveighoffer
On Tue, 22 Jun 2010 05:04:18 -0400, Lars T. Kyllingstad  
pub...@kyllingen.nospamnet wrote:



On Mon, 21 Jun 2010 14:51:01 -0400, Steven Schveighoffer wrote:


I've been trying to get a modified version of std.process to compile
(with Lars K's changes) for windows, and phobos finally compiled.

So I built a little test program, compiled it, and I get the following
error message:

object.Exception: circular dependency in module std.stdio.

Great.  How did that happen?  Being that I didn't write std.stdio, only
modified it slightly (and certainly didn't change any imports), I
haven't the foggiest where this problem is.  Given that the runtime can
prove there is a circular dependency, and apparently knows the names of
the modules, how about showing me the cycle?

:P

I do not look forward to tracking this one down...

-Steve



I think the only places that exception can be thrown are lines 1770 and
1830 of object.d.  Luckily there are a few debug(PRINTF)printf()s
nearby.  You could try building druntime with -debug=PRINTF.  When the
static constructors are run, hopefully you'll see something like

  ...
  module[x] = std.stdio
  ...
  module[y] = module.depending.cyclically.on.stdio
  module[z] = std.stdio
  object.Exception: Cyclic dependency in module std.stdio.


This is a good idea.

I'm going to look at the runtime to see if I can add code that prints the  
cycle only on failure.  I think such code could be invaluable.  I wonder  
if a stack trace would be enough...


-Steve


Re: This just in: authorless TDPL becomes collector's edition

2010-06-22 Thread Tyro[a.c.edwards]
good for you, sucks for me though, I didn't get a collector's edition
and I ordered my copy back in over six months ago.


Re: Latest string_token Code

2010-06-22 Thread Ben Hanson
== Quote from Rory McGuire (rmcgu...@neonova.co.za)'s article
 I think sizeof is a property, e.g. char.sizeof or:
 struct A {
   int a;
   char[10] b;
 }
 A.sizeof
 A a;
 a.sizeof
 you get the picture. (Have I got it?)
 -Rory

Thanks Rory.


Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-22 Thread Steven Schveighoffer
On Mon, 21 Jun 2010 20:40:14 -0400, Adam Ruppe destructiona...@gmail.com  
wrote:



What's the point of a switch without implicit fallthrough?


Maintenance.  Using if statements instead of switch, you have to repeat  
the value to test for each of the cases.  If you want to change the value  
being tested, it's one change.  And your workaround using a delegate is  
not very appealing.


I'll also point out that popular languages have a switch statement and  
don't allow implicit fallthrough, meaning that 100% of switch statements  
do not have fallthrough.  And switch is used quite often in those  
languages too, so at least some people think it has use besides allowing  
implcit fallthrough.


I think mostly it's because the meaning of it is so easy to understand  
when reading/writing it.  When you see a switch, you know what it is and  
what it isn't.  An if statement has many possibilities and must be read  
more carefully.


-Steve


Re: Improving std.regex(p)

2010-06-22 Thread Ben Hanson
== Quote from Nick Sabalausky (a...@a.a)'s article
 Ben Hanson ben.han...@tfbplc.co.uk wrote in message
 news:hvj9i1$1q7...@digitalmars.com...
  Lua has an interesting pattern matcher, as it goes more in
  the formal grammar direction to (for example) match balanced parenthesis
  etc.
 That's cool. That's something I've often wanted in regexes (It would be
 great for defining lever tokens in a grammar-definition language), and
 though I'm no FSA or regex expert, it always seemed like something entirely
 doable without having to resort to a full-blown LL or LR parser.

Yeah, it does seem obvious that there'd be some middle ground between regexes -
certainly the author of the LUA pattern matching thought so! :-) The topic could
definitely do with more attention.

There is limited back-tracking in the LUA pattern matching, which I don't like,
but it appears more efficient than back-tracking NFA.  Apparantly it has some
solid theory behind it too, which is good. Sadly just not enough time to persue
all these possibilities...

Regards,

Ben


Re: finding a circular dependency

2010-06-22 Thread Rory McGuire
On Tue, 22 Jun 2010 13:02:53 +0200, Steven Schveighoffer  
schvei...@yahoo.com wrote:


On Tue, 22 Jun 2010 03:14:38 -0400, Rory McGuire  
rmcgu...@neonova.co.za wrote:


On Mon, 21 Jun 2010 20:51:01 +0200, Steven Schveighoffer  
schvei...@yahoo.com wrote:


I've been trying to get a modified version of std.process to compile  
(with Lars K's changes) for windows, and phobos finally compiled.


So I built a little test program, compiled it, and I get the following  
error message:


object.Exception: circular dependency in module std.stdio.

Great.  How did that happen?  Being that I didn't write std.stdio,  
only modified it slightly (and certainly didn't change any imports), I  
haven't the foggiest where this problem is.  Given that the runtime  
can prove there is a circular dependency, and apparently knows the  
names of the modules, how about showing me the cycle?


:P

I do not look forward to tracking this one down...

-Steve


doesn't -verbose list the modules dmd is importing? Perhaps it stops at  
the offending module?


It's a runtime issue, not a compiler issue.

-Steve


Doh! now I remember, its because of the static constructors having a  
specific order (from tdpl).
And it only does construction when you run the app, not when compiling.  
(elaborating on your reply).


Thanks


Re: Improving std.regex(p)

2010-06-22 Thread Ben.Hanson
== Quote from BCS (n...@anon.com)'s article
 Hello Ben,
  The only reason they were interested in my lexer generator is that
  recursive descent lexing is pretty slow. So for more demanding
  grammars, a DFA based lexer is better. The lexer library allows you to
  create a lexer at runtime (which doesn't fit in so well with their
  model of doing everything at compile time), or you can generate code
  offline and then just add that to your project. This is why a compile
  time DFA lexer would be really interesting to them.
 
  The biggest problem (as far as I can
  see as an observer) is the compile times.
 I've never got a usable grammer for D to feed into it but I did get one (~200
 productions) that at least compiled: it took 7 (or 17 minutes, I forget)
 and 700MB or ram To compile (P-III 550MHz, 700MB RAM)
  This is where D could be
  really interesting overall (Hartmut has certainly got his eye on it
  and in fact I'm sure all the Boost people do).
 
  For my part, I'd like to see an LR parser generator developed. I'd be
  happy with one that creates the parser at runtime (assuming decent
  performance), but if it can generate and compile code efficiently at
  compile time, so much the better! :-) I really like the idea of being
  able to switch the runtime/compile time behaviour.
 
 Given that most LR parsers are table driven, all that would be needed for
 a compile time system would be that the table generator be evaluateable at
 compile time. The result could be stored in a constant. The only tricky bits
 then would be handling the data values on the stack and the part to tack
 in the action rules and that could just be a naming convention:
 class MyActions
 {
 resultType Action_statement_if(/+ args +/) { /+ code +/ }
 resultType Action_statement_ifThen(/+ args +/) { /+ code +/ }
 resultType Action_addExpression_plus(/+ args +/) { /+ code +/ }
 resultType Action_addExpression_minus(/+ args +/) { /+ code +/ }
 resultType Action_addExpression_chain(/+ args +/) { /+ code +/ }
 // ...
 mixin Parser!(
 `statment : if ( expression ) statment / if
   | if ( expression ) statment then statment / ifThen
   | { statment* } / block
   | expression ; /expression;
 addExpression : .
 `);
 }
 Parser!(string) would generate a function that just assumes the existence
 of functions of the given names.
Let's come back to this! For now I will concentrate on the regex stuff and 
review
the Sweet Parser for the Spirit guys.

Regards,

Ben


Re: Improving std.regex(p)

2010-06-22 Thread Ben Hanson
== Quote from div0 (d...@users.sourceforge.net)'s article
 On 19/06/2010 20:39, Ben Hanson wrote:
   From memory (Joel did a PDF recently, but that is on my works machine) 
  Joel has
  been developing Spirit for over ten years. The latest version is pretty
  sophisticated and has all kinds of clever stuff for directly parsing data in
  structures all inline etc. Needless to say, I find the whole thing pretty 
  mind
  boggling. The biggest problem (as far as I can see as an observer) is the
  compile times. This is where D could be really interesting overall (Hartmut 
  has
  certainly got his eye on it and in fact I'm sure all the Boost people do).
 I ported most of the classic version of spirit to d a while back.
 I've recently written a XML parser using it and it takes nearly 7 whole
 seconds to compile with DMD, which is a vast amount of time compared to
 rest of the stuff I compile. :)
 The most trivial spirit parser in c++ takes over 30 seconds on my
 machine, even with everything in the pre compiled header. D is just a
 massive win for productively.

Faster compile time code generation is a massive advantage for D.

Hartmut contacted me about a runtime LALR parser generator called Sweet Parser
(http://www.sweetsoftware.co.nz/parser_overview.php). They've contacted the 
author
about integrating a version of that into Spirit. A version in D that could run 
at
compile time would be cool too...

Bizzare timing or what!

It looks like interesting times lie ahead...

Regards,

Ben


Re: Latest string_token Code

2010-06-22 Thread bearophile
Ben Hanson:
 The underscores thing just comes from the C++ source.

But once your program works well you can change the variable names a little, or 
even before if you have some kind of IDE.

In D style guide structs and classes need to start with an upper case, in 
CamelCase. And variable names are written in camelCase with a starting lower 
case:
http://www.digitalmars.com/d/2.0/dstyle.html
Following a common style guide is important.


 I was recommended that
 approach, as not wanting to use Reverse Polish Notation (i.e. MFC style),

I think you mean polish with no reverse :-)


 the underscores allow you to have a type the same name as a member var or 
 local var.

I don't understand.
Why can't you write the code like this?

struct BasicStringToken
{
enum size_t MAX_CHARS = CharT.max + 1;
enum size_t START_CHAR = cast(CharT) 0x80  0 ? 0x80 : 0;

private bool negated = false;
private CharT[] charset;

this(const bool negated_, ref CharT[] charset_)
{
negated = negated_;
charset = charset_;
}

I have kept the underscores in the arguments of the method because they have a 
limited scope/life, so they don't add a lot of noise to the whole code.

Bye,
bearophile


Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-22 Thread Jeff Nowakowski

On 06/22/2010 12:06 AM, Don wrote:

Finally, goto is ugly and continue is strongly associated with looping.


? It's most commonly used in error handling.
But, fallthrough actually is a goto.


Do I really have to argue that goto is mostly deprecated, and has been 
for decades? Lots of programming constructs are specialized versions of 
goto. Sure, a well placed goto can still be good in some error handling 
situations, but it's use should be limited.


Anyways, I find it interesting that somebody in another post said they 
already put //fallthrough comment in their code, which supports that the 
most obvious and simplest thing to do is make it a keyword. It would 
also make for a good suggestion in an error message: fallthrough required.


Re: Latest string_token Code

2010-06-22 Thread Ben Hanson
== Quote from bearophile (bearophileh...@lycos.com)'s article
 Ben Hanson:
  The underscores thing just comes from the C++ source.
 But once your program works well you can change the variable names a little, 
 or
even before if you have some kind of IDE.
 In D style guide structs and classes need to start with an upper case, in
CamelCase. And variable names are written in camelCase with a starting lower 
case:
 http://www.digitalmars.com/d/2.0/dstyle.html
 Following a common style guide is important.
I'm happy to change the naming style when things are running.
  I was recommended that
  approach, as not wanting to use Reverse Polish Notation (i.e. MFC style),
 I think you mean polish with no reverse :-)
RPN is for compilers isn't it?! I think it was called Hungarian Notation 
(possibly)...
  the underscores allow you to have a type the same name as a member var or
local var.
 I don't understand.
 Why can't you write the code like this?
 struct BasicStringToken
 {
 enum size_t MAX_CHARS = CharT.max + 1;
 enum size_t START_CHAR = cast(CharT) 0x80  0 ? 0x80 : 0;
 private bool negated = false;
 private CharT[] charset;
 this(const bool negated_, ref CharT[] charset_)
 {
 negated = negated_;
 charset = charset_;
 }
 I have kept the underscores in the arguments of the method because they have a
limited scope/life, so they don't add a lot of noise to the whole code.
The code so far isn't a good example of that, but it's generally when you
typedefed a template and then wanted to name a var with the same name as the 
type.
Regardles, as you pointed out, D does things differently, which is fine.

Regards,

Ben


Re: enforce()?

2010-06-22 Thread Simen kjaeraas

BCS n...@anon.com wrote:

I think that for such situations you should ship a debug and release
version of the DLL.
This way you don't sacrifice performance when the user doesn't want to
be
held by the hand.


Until you can show me a perf problem, I don't see any point in doing  
that. (OTOH, deep structure validation, or anything else slower than  
O(1), is another thing all together)


Also, if you do have two different versions, I'll bet you ready money
someone will program only the release version, because that's the
version the users will have, the debug version is slow or whatever
other inane excuse their minds are capable of coming up with.

--
Simen


Re: Latest string_token Code

2010-06-22 Thread Ben Hanson
 == Quote from bearophile (bearophileh...@lycos.com)'s article
  In D style guide structs and classes need to start with an upper case, in
 CamelCase. And variable names are written in camelCase with a starting lower 
 case:
  http://www.digitalmars.com/d/2.0/dstyle.html
  Following a common style guide is important.
Actually, I may as well convert as I go.

Regards,

Ben


Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-22 Thread Simen kjaeraas
On Tue, 22 Jun 2010 02:40:14 +0200, Adam Ruppe destructiona...@gmail.com  
wrote:



What's the point of a switch without implicit fallthrough? If you take
that away, it offers nothing that if/elseif doesn't. (Aside from not
retyping the switch(stuff here), which you can bring into a function
anyway, so whoop-de-doo. And I guess some performance boosts in
rearranging the cases, but can't the optimizer do that in if/else
anyway?)

int Case(in int value) { return myvar == value; }

if(Case(10)) {

} else if (Case(20)) {

} else  { /* default */ }

You can even use goto and labels to simulate goto case.


Well, if you like sacrificing clarity for writing more verbose
code, feel free.

Switch is valuable for its clarity - '} else if (Case(12)) {' is
nowhere near as easily parsable as 'case 12'.

--
Simen


readf anyone?

2010-06-22 Thread Tyro[a.c.edwards]
So I'm digging in and enjoying the read (and let me tell you it's a
pretty interesting read), then I flip to page 22 (I read slow) and
stumbled onto this code:

for (double x; readf( % , x) == 1; ) {
   [snip]
}

Wait that don't look right. I don't remember readf() being
implemented. So I decided to check things out. I jimmied up this
little rig:

void main() {
double q;
readf(%s, q);
writeln(q);
}

and launched it:

D:\codedmd input
input.d(5): Error: undefined identifier readf, did you mean function
readln?

well that didn't work. Maybe I'm missing something. Let me take a
look an the phobos doc: no, no mention there. Oh, I got it, I don't
have the latest compiler (how stupid of me). Downloading...
Installing... recompiling. Damn, that wasn't it. Ok, let me take a
look at std.stdio.d. There it is, it's a member function of class
File. Ok, I should be able to access it through stdin. Let me try
that instead:

void main() {
double q;
stdin.readf(%s, q);
writeln(q);
}

Here goes nothing:

D:\codedmd read
d:\dmd2\windows\bin\..\..\src\phobos\std\format.d(2948): Error: no
property 'len
gth' for type 'InputByChar'

Damn, that didn't work either. Now that's crazy, why would we use
this function in the book and not take the extra effort to ensure
that it's actually implemented before going to print? Was this an
oversight? If so, can we please get the fix.


Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-22 Thread Don

Jeff Nowakowski wrote:

On 06/22/2010 12:06 AM, Don wrote:

Finally, goto is ugly and continue is strongly associated with looping.


? It's most commonly used in error handling.
But, fallthrough actually is a goto.


Do I really have to argue that goto is mostly deprecated, and has been 
for decades? 


I think you misunderstood. I was arguing that there is no association 
between 'goto' and loops. People who use goto, use it for error 
handling, not for looping. I was by no means advocating the use of goto 
for error handling!


Re: This just in: authorless TDPL becomes collector's edition

2010-06-22 Thread Jacob Carlborg

On 2010-06-21 21:23, Mike James wrote:

Got my collectors item  delivered today from Amazon UK. Looks good. I like
the bonus of being able to download a PDF version of TDPL.

Thanks for all the hard work Andrei.

-=mike=-

Andrei Alexandrescuseewebsiteforem...@erdani.org  wrote in message
news:hu3hq6$2f0...@digitalmars.com...

Due to a pretty odd mistake at the printer, the first 1000 copies of TDPL
will not have the name of the author on their cover. (The name still
appears on the back cover and the spine.)

The history of printing is rife with rare printing mistakes that have
become collector's editions. Preorder now to be among the first 1000
readers who get the authorless TDPL edition.


Andrei


What happened to the nice looking PDF file we saw previews on, that one 
with syntax highlighting and a green background in the code example?



--
/Jacob Carlborg


Re: Errors in TDPL

2010-06-22 Thread Andrei Alexandrescu

On 06/22/2010 07:18 AM, bearophile wrote:

So I suggest to replace that line in the iota() costructor with:

enforce(step != 0);

And then create an empty generator if pastLast= current (and the step is 1).


Absolutely. I wrote that test to simplify my life, but in the final 
version iota should accept empty ranges.


Andrei


Re: This just in: authorless TDPL becomes collector's edition

2010-06-22 Thread Andrei Alexandrescu

On 06/22/2010 07:45 AM, Jacob Carlborg wrote:

On 2010-06-21 21:23, Mike James wrote:

Got my collectors item delivered today from Amazon UK. Looks good. I
like
the bonus of being able to download a PDF version of TDPL.

Thanks for all the hard work Andrei.

-=mike=-

Andrei Alexandrescuseewebsiteforem...@erdani.org wrote in message
news:hu3hq6$2f0...@digitalmars.com...

Due to a pretty odd mistake at the printer, the first 1000 copies of
TDPL
will not have the name of the author on their cover. (The name still
appears on the back cover and the spine.)

The history of printing is rife with rare printing mistakes that have
become collector's editions. Preorder now to be among the first 1000
readers who get the authorless TDPL edition.


Andrei


What happened to the nice looking PDF file we saw previews on, that one
with syntax highlighting and a green background in the code example?


That's the iPad edition :o).

Now seriously, what happens is that what you see is exactly what went to 
the printer. I can configure colors for a color edition, but for now the 
publisher asked me for black and white.


Andrei


Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-22 Thread Leandro Lucarella
Steven Schveighoffer, el 22 de junio a las 07:26 me escribiste:
 On Mon, 21 Jun 2010 20:40:14 -0400, Adam Ruppe
 destructiona...@gmail.com wrote:
 
 What's the point of a switch without implicit fallthrough?
 
 Maintenance.  Using if statements instead of switch, you have to
 repeat the value to test for each of the cases.  If you want to
 change the value being tested, it's one change.  And your workaround
 using a delegate is not very appealing.

And it's a bit comfortable when used with expressions that should be
evaluated just one:

switch (foo()) {
case xxx:
...
case yyy:
...
}

vs

auto tmp = foo();
if (tmp == xxx) {
...
else if (tmp == yyy) {
...
}

 I'll also point out that popular languages have a switch statement
 and don't allow implicit fallthrough, meaning that 100% of switch
 statements do not have fallthrough.  And switch is used quite often
 in those languages too, so at least some people think it has use
 besides allowing implcit fallthrough.
 
 I think mostly it's because the meaning of it is so easy to
 understand when reading/writing it.  When you see a switch, you know
 what it is and what it isn't.  An if statement has many
 possibilities and must be read more carefully.

Like for/while vs goto and foreach vs while/for. They are
specializations for common uses. It helps both the programmer to
write/read more clear code and the compiler to generate more efficient
code because they have a more defined semantics and it can make more
assumptions.

-- 
Leandro Lucarella (AKA luca) http://llucax.com.ar/
--
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
--
Creativity is great but plagiarism is faster


Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-22 Thread Leandro Lucarella
Lars T. Kyllingstad, el 22 de junio a las 09:14 me escribiste:
 On Mon, 21 Jun 2010 20:27:32 -0700, Bill Baxter wrote:
 
  On Mon, Jun 21, 2010 at 6:31 PM, Leandro Lucarella l...@llucax.com.ar
  wrote:
  Bill Baxter, el 21 de junio a las 17:13 me escribiste:
  On Mon, Jun 21, 2010 at 4:24 PM, Leandro Lucarella
  l...@llucax.com.ar wrote:
   goto next case; is a little more verbose but very clear to me :)
  
   Maybe just next case; is a shorter alternative...
 
  That would be great if next were a D keyword.  But I don't think
  you're going to get Walter to add a keyword just for this.
 
  Damn! Where did I get next from? I don't know...
  
  I think it's a keyword in Perl maybe?
  
  --bb
 
 It is a keyword in BASIC, at least. :)
 
   FOR i = 1 TO 100
 PRINT i
   NEXT

I'm sure it's Perl, even when I written Basic (GW and Q) code,
I remember it having the same meaning as C's continue.

-- 
Leandro Lucarella (AKA luca) http://llucax.com.ar/
--
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
--
According to several sources
Dr. Harvey Kellogg tried to make a cure for masturbation
When he made cornflakes


Re: DMD Backend Long-term

2010-06-22 Thread Leandro Lucarella
Kagamin, el 22 de junio a las 07:01 me escribiste:
 Robert Jacques Wrote:
 
  The main issue (as I understand it) is adding windows style structured  
  exception handling to LLVM.
 
 C++ compiles for me. Or are there some other issues?

LDC compiles too, but it doesn't support exceptions. I guess is the same
with C++.

-- 
Leandro Lucarella (AKA luca) http://llucax.com.ar/
--
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
--
'It's not you, it's me'? You're giving me the 'It's not you, it's me'
routine? I invented 'It's not you, it's me.' Nobody tells me it's them,
not me. If it's anybody, it's me.
-- George Constanza


Re: Latest string_token Code

2010-06-22 Thread Ben Hanson
Here's the latest with naming convention (hopefully) followed. I've implemented 
my
own squeeze() function and used sizeof in the memmove calls.

How can I specify wide strings for the literals?

Thanks,

Ben

module main;

import std.algorithm;
import std.array;
import std.c.string;
import std.string;

import std.stdio;

template regex(CharT)
{
struct BasicStringToken
{
bool negated = false;
CharT[] charset;
enum size_t MAX_CHARS = CharT.max + 1;
enum size_t START_CHAR = cast(CharT) 0x80  0 ? 0x80 : 0;

this(const bool negated_, ref CharT[] charset_)
{
negated = negated_;
charset = charset_;
}

void removeDuplicates()
{
charset.sort;
squeeze(charset);
}

void normalise()
{
if (charset.length == MAX_CHARS)
{
negated = !negated;
charset.clear();
}
else if (charset.length  MAX_CHARS / 2)
{
negate();
}
}

void negate()
{
CharT curr_char = START_CHAR;
CharT[] temp;
CharT *ptr = cast(CharT *) 0;
CharT *curr = charset.ptr;
CharT *end = curr + charset.length;
size_t i = 0;

negated = !negated;
temp.length = MAX_CHARS - charset.length;
ptr = temp.ptr;

while (curr  end)
{
while (*curr  curr_char)
{
*ptr = curr_char;
++ptr;
++curr_char;
++i;
}

++curr_char;
++curr;
++i;
}

for (; i  MAX_CHARS; ++i)
{
*ptr = curr_char;
++ptr;
++curr_char;
}

charset = temp;
}

bool empty()
{
return charset.length == 0  !negated;
}

bool any()
{
return charset.length == 0  negated;
}

void clear()
{
negated = false;
charset.length = 0;
}

void intersect(ref BasicStringToken rhs,
ref BasicStringToken overlap)
{
if ((any()  rhs.any()) || (negated == rhs.negated 
!any()  !rhs.any()))
{
intersectSameTypes(rhs, overlap);
}
else
{
intersectDiffTypes(rhs, overlap);
}
}

private:
void intersectSameTypes(ref BasicStringToken rhs,
ref BasicStringToken overlap)
{
if (any())
{
clear();
overlap.negated = true;
rhs.clear();
}
else
{
CharT *iter = charset.ptr;
CharT *end = iter + charset.length;
CharT *rhs_iter = rhs.charset.ptr;
CharT *rhs_end = rhs_iter + rhs.charset.length;

overlap.negated = negated;

while (iter != end  rhs_iter != rhs_end)
{
if (*iter  *rhs_iter)
{
++iter;
}
else if (*iter  *rhs_iter)
{
++rhs_iter;
}
else
{
overlap.charset ~= *iter;
memmove(iter, iter + 1, (charset.ptr +
charset.length - iter) * CharT.sizeof);
--end;
charset.length -= 1;
memmove(rhs_iter, rhs_iter + 1, (rhs.charset.ptr +
rhs.charset.length - rhs_iter) * CharT.sizeof);
--rhs_end;
rhs.charset.length -= 1;
}
}

if (negated)
{
// duplicates already merged
// src, dest
merge(charset, overlap.charset);
// duplicates already merged
// src, dest
merge(rhs.charset, overlap.charset);
negated = false;
rhs.negated = false;
swap(charset, rhs.charset);
normalise();
overlap.normalise();
rhs.normalise();
}
else if (!overlap.charset.length == 0)
{
normalise();
overlap.normalise();
rhs.normalise();
}
}
}

void intersectDiffTypes(ref BasicStringToken rhs,
ref BasicStringToken overlap)
{
if (any())
{
intersectAny(rhs, overlap);
}
else if (negated)
{
intersectNegated(rhs, overlap);
}
else // negated == false
{
intersectCharset(rhs, overlap);
}
}

void intersectAny(ref BasicStringToken rhs, ref BasicStringToken overlap)
{
if (rhs.negated)
{
rhs.intersectNegated(this, overlap);
}
else // rhs.negated == false
{
rhs.intersectCharset(this, overlap);
}
}

void 

Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-22 Thread Adam Ruppe
What you guys are saying makes enough sense. switch will always be a
series of labels and jumps in my mind, but I can deal with this.

One note that I think is the main reason people find fallthrough
confusing: they hit tab once too many times.

switch(a) {
case 10:
case 20: // obvious fallthrough, no break directly above it
break; // obvious break - same indentation as the case, just like
braces would be
case 30:
}

I notice a lot of other people indent the break further than the case,
which is something I only do if the break is not the last statement
(which means it is probably indented twice, being inside an if or
something.)


Oh well.


Re: Latest string_token Code

2010-06-22 Thread Rory McGuire

the stringw

gives you 16bit I believe. postfix with a 'd' should give you 32bit.



On Tue, 22 Jun 2010 15:13:06 +0200, Ben Hanson ben.han...@tfbplc.co.uk  
wrote:


Here's the latest with naming convention (hopefully) followed. I've  
implemented my

own squeeze() function and used sizeof in the memmove calls.

How can I specify wide strings for the literals?

Thanks,

Ben

module main;

import std.algorithm;
import std.array;
import std.c.string;
import std.string;

import std.stdio;

template regex(CharT)
{
struct BasicStringToken
{
bool negated = false;
CharT[] charset;
enum size_t MAX_CHARS = CharT.max + 1;
enum size_t START_CHAR = cast(CharT) 0x80  0 ? 0x80 : 0;

this(const bool negated_, ref CharT[] charset_)
{
negated = negated_;
charset = charset_;
}

void removeDuplicates()
{
charset.sort;
squeeze(charset);
}

void normalise()
{
if (charset.length == MAX_CHARS)
{
negated = !negated;
charset.clear();
}
else if (charset.length  MAX_CHARS / 2)
{
negate();
}
}

void negate()
{
CharT curr_char = START_CHAR;
CharT[] temp;
CharT *ptr = cast(CharT *) 0;
CharT *curr = charset.ptr;
CharT *end = curr + charset.length;
size_t i = 0;

negated = !negated;
temp.length = MAX_CHARS - charset.length;
ptr = temp.ptr;

while (curr  end)
{
while (*curr  curr_char)
{
*ptr = curr_char;
++ptr;
++curr_char;
++i;
}

++curr_char;
++curr;
++i;
}

for (; i  MAX_CHARS; ++i)
{
*ptr = curr_char;
++ptr;
++curr_char;
}

charset = temp;
}

bool empty()
{
return charset.length == 0  !negated;
}

bool any()
{
return charset.length == 0  negated;
}

void clear()
{
negated = false;
charset.length = 0;
}

void intersect(ref BasicStringToken rhs,
ref BasicStringToken overlap)
{
if ((any()  rhs.any()) || (negated == rhs.negated 
!any()  !rhs.any()))
{
intersectSameTypes(rhs, overlap);
}
else
{
intersectDiffTypes(rhs, overlap);
}
}

private:
void intersectSameTypes(ref BasicStringToken rhs,
ref BasicStringToken overlap)
{
if (any())
{
clear();
overlap.negated = true;
rhs.clear();
}
else
{
CharT *iter = charset.ptr;
CharT *end = iter + charset.length;
CharT *rhs_iter = rhs.charset.ptr;
CharT *rhs_end = rhs_iter + rhs.charset.length;

overlap.negated = negated;

while (iter != end  rhs_iter != rhs_end)
{
if (*iter  *rhs_iter)
{
++iter;
}
else if (*iter  *rhs_iter)
{
++rhs_iter;
}
else
{
overlap.charset ~= *iter;
memmove(iter, iter + 1, (charset.ptr +
charset.length - iter) * CharT.sizeof);
--end;
charset.length -= 1;
memmove(rhs_iter, rhs_iter + 1, (rhs.charset.ptr +
rhs.charset.length - rhs_iter) * CharT.sizeof);
--rhs_end;
rhs.charset.length -= 1;
}
}

if (negated)
{
// duplicates already merged
// src, dest
merge(charset, overlap.charset);
// duplicates already merged
// src, dest
merge(rhs.charset, overlap.charset);
negated = false;
rhs.negated = false;
swap(charset, rhs.charset);
normalise();
overlap.normalise();
rhs.normalise();
}
else if (!overlap.charset.length == 0)
{
normalise();
overlap.normalise();
rhs.normalise();
}
}
}

void intersectDiffTypes(ref BasicStringToken rhs,
ref BasicStringToken overlap)
{
if (any())
{
intersectAny(rhs, overlap);
}
else if (negated)
{
intersectNegated(rhs, overlap);
}
else // negated == false
{
intersectCharset(rhs, overlap);
}
}

void intersectAny(ref BasicStringToken rhs, ref BasicStringToken  
overlap)

{
if (rhs.negated)
{

Re: Latest string_token Code

2010-06-22 Thread Ben Hanson
== Quote from Rory McGuire (rmcgu...@neonova.co.za)'s article
 On Tue, 22 Jun 2010 15:13:06 +0200, Ben Hanson ben.han...@tfbplc.co.uk
 wrote:
  Here's the latest with naming convention (hopefully) followed. I've
  implemented my
  own squeeze() function and used sizeof in the memmove calls.
 
  How can I specify wide strings for the literals?
 
  Thanks,
 
  Ben
 
  module main;
 
  import std.algorithm;
  import std.array;
  import std.c.string;
  import std.string;
 
  import std.stdio;
 
  template regex(CharT)
  {
  struct BasicStringToken
  {
  bool negated = false;
  CharT[] charset;
  enum size_t MAX_CHARS = CharT.max + 1;
  enum size_t START_CHAR = cast(CharT) 0x80  0 ? 0x80 : 0;
 
  this(const bool negated_, ref CharT[] charset_)
  {
  negated = negated_;
  charset = charset_;
  }
 
  void removeDuplicates()
  {
  charset.sort;
  squeeze(charset);
  }
 
  void normalise()
  {
  if (charset.length == MAX_CHARS)
  {
  negated = !negated;
  charset.clear();
  }
  else if (charset.length  MAX_CHARS / 2)
  {
  negate();
  }
  }
 
  void negate()
  {
  CharT curr_char = START_CHAR;
  CharT[] temp;
  CharT *ptr = cast(CharT *) 0;
  CharT *curr = charset.ptr;
  CharT *end = curr + charset.length;
  size_t i = 0;
 
  negated = !negated;
  temp.length = MAX_CHARS - charset.length;
  ptr = temp.ptr;
 
  while (curr  end)
  {
  while (*curr  curr_char)
  {
  *ptr = curr_char;
  ++ptr;
  ++curr_char;
  ++i;
  }
 
  ++curr_char;
  ++curr;
  ++i;
  }
 
  for (; i  MAX_CHARS; ++i)
  {
  *ptr = curr_char;
  ++ptr;
  ++curr_char;
  }
 
  charset = temp;
  }
 
  bool empty()
  {
  return charset.length == 0  !negated;
  }
 
  bool any()
  {
  return charset.length == 0  negated;
  }
 
  void clear()
  {
  negated = false;
  charset.length = 0;
  }
 
  void intersect(ref BasicStringToken rhs,
  ref BasicStringToken overlap)
  {
  if ((any()  rhs.any()) || (negated == rhs.negated 
  !any()  !rhs.any()))
  {
  intersectSameTypes(rhs, overlap);
  }
  else
  {
  intersectDiffTypes(rhs, overlap);
  }
  }
 
  private:
  void intersectSameTypes(ref BasicStringToken rhs,
  ref BasicStringToken overlap)
  {
  if (any())
  {
  clear();
  overlap.negated = true;
  rhs.clear();
  }
  else
  {
  CharT *iter = charset.ptr;
  CharT *end = iter + charset.length;
  CharT *rhs_iter = rhs.charset.ptr;
  CharT *rhs_end = rhs_iter + rhs.charset.length;
 
  overlap.negated = negated;
 
  while (iter != end  rhs_iter != rhs_end)
  {
  if (*iter  *rhs_iter)
  {
  ++iter;
  }
  else if (*iter  *rhs_iter)
  {
  ++rhs_iter;
  }
  else
  {
  overlap.charset ~= *iter;
  memmove(iter, iter + 1, (charset.ptr +
  charset.length - iter) * CharT.sizeof);
  --end;
  charset.length -= 1;
  memmove(rhs_iter, rhs_iter + 1, (rhs.charset.ptr +
  rhs.charset.length - rhs_iter) * CharT.sizeof);
  --rhs_end;
  rhs.charset.length -= 1;
  }
  }
 
  if (negated)
  {
  // duplicates already merged
  // src, dest
  merge(charset, overlap.charset);
  // duplicates already merged
  // src, dest
  merge(rhs.charset, overlap.charset);
  negated = false;
  rhs.negated = false;
  swap(charset, rhs.charset);
  normalise();
  overlap.normalise();
  rhs.normalise();
  }
  else if (!overlap.charset.length == 0)
  {
  normalise();
  overlap.normalise();
  rhs.normalise();
  }
  }
  }
 
  void intersectDiffTypes(ref BasicStringToken rhs,
  ref BasicStringToken overlap)
  {
  if (any())
  {
  intersectAny(rhs, overlap);
   

Re: Errors in TDPL

2010-06-22 Thread Walter Bright

biozic wrote:

Le 22/06/10 10:54, Walter Bright a écrit :

Andrei Alexandrescu wrote:

On 06/21/2010 08:47 PM, Jonathan M Davis wrote:

On page 82 of TDPL, it's talking about try/catch/finally statements,
and it
says that all controlled statement must be block statements; that is
they
must be enclosed with braces. However, dmd does not seem to require
that
try/catch/finally blocks have braces, which is what I would expect that
sentence to mean. C++ has that restriction for reasons that I don't
understand, but as far as I can tell, D does not - certainly dmd 
doesn't

appear to require it. Is the statement correct but refers to
something else,
or is it in error?

- Jonathan M Davis


That's a surprise to me. Walter, is that intentional?


They do not require braces, they just require that the controlling
statement not be a single ;. In the grammar, this is a ScopeStatement,
which is a NonEmptyStatement or a BlockStatement.


http://www.digitalmars.com/d/2.0/statement.html#ScopeStatement


Not always: http://d.puremagic.com/issues/show_bug.cgi?id=4024


Bugs in the compiler aren't errors in TDPL!


Re: Latest string_token Code

2010-06-22 Thread Rory McGuire
On Tue, 22 Jun 2010 15:31:14 +0200, Ben Hanson ben.han...@tfbplc.co.uk  
wrote:



== Quote from Rory McGuire (rmcgu...@neonova.co.za)'s article

On Tue, 22 Jun 2010 15:13:06 +0200, Ben Hanson ben.han...@tfbplc.co.uk
wrote:
 Here's the latest with naming convention (hopefully) followed. I've
 implemented my
 own squeeze() function and used sizeof in the memmove calls.

 How can I specify wide strings for the literals?

 Thanks,

 Ben

 module main;

 import std.algorithm;
 import std.array;
 import std.c.string;
 import std.string;

 import std.stdio;

 template regex(CharT)
 {
 struct BasicStringToken
 {
 bool negated = false;
 CharT[] charset;
 enum size_t MAX_CHARS = CharT.max + 1;
 enum size_t START_CHAR = cast(CharT) 0x80  0 ? 0x80 : 0;

 this(const bool negated_, ref CharT[] charset_)
 {
 negated = negated_;
 charset = charset_;
 }

 void removeDuplicates()
 {
 charset.sort;
 squeeze(charset);
 }

 void normalise()
 {
 if (charset.length == MAX_CHARS)
 {
 negated = !negated;
 charset.clear();
 }
 else if (charset.length  MAX_CHARS / 2)
 {
 negate();
 }
 }

 void negate()
 {
 CharT curr_char = START_CHAR;
 CharT[] temp;
 CharT *ptr = cast(CharT *) 0;
 CharT *curr = charset.ptr;
 CharT *end = curr + charset.length;
 size_t i = 0;

 negated = !negated;
 temp.length = MAX_CHARS - charset.length;
 ptr = temp.ptr;

 while (curr  end)
 {
 while (*curr  curr_char)
 {
 *ptr = curr_char;
 ++ptr;
 ++curr_char;
 ++i;
 }

 ++curr_char;
 ++curr;
 ++i;
 }

 for (; i  MAX_CHARS; ++i)
 {
 *ptr = curr_char;
 ++ptr;
 ++curr_char;
 }

 charset = temp;
 }

 bool empty()
 {
 return charset.length == 0  !negated;
 }

 bool any()
 {
 return charset.length == 0  negated;
 }

 void clear()
 {
 negated = false;
 charset.length = 0;
 }

 void intersect(ref BasicStringToken rhs,
 ref BasicStringToken overlap)
 {
 if ((any()  rhs.any()) || (negated == rhs.negated 
 !any()  !rhs.any()))
 {
 intersectSameTypes(rhs, overlap);
 }
 else
 {
 intersectDiffTypes(rhs, overlap);
 }
 }

 private:
 void intersectSameTypes(ref BasicStringToken rhs,
 ref BasicStringToken overlap)
 {
 if (any())
 {
 clear();
 overlap.negated = true;
 rhs.clear();
 }
 else
 {
 CharT *iter = charset.ptr;
 CharT *end = iter + charset.length;
 CharT *rhs_iter = rhs.charset.ptr;
 CharT *rhs_end = rhs_iter + rhs.charset.length;

 overlap.negated = negated;

 while (iter != end  rhs_iter != rhs_end)
 {
 if (*iter  *rhs_iter)
 {
 ++iter;
 }
 else if (*iter  *rhs_iter)
 {
 ++rhs_iter;
 }
 else
 {
 overlap.charset ~= *iter;
 memmove(iter, iter + 1, (charset.ptr +
 charset.length - iter) * CharT.sizeof);
 --end;
 charset.length -= 1;
 memmove(rhs_iter, rhs_iter + 1, (rhs.charset.ptr +
 rhs.charset.length - rhs_iter) *  
CharT.sizeof);

 --rhs_end;
 rhs.charset.length -= 1;
 }
 }

 if (negated)
 {
 // duplicates already merged
 // src, dest
 merge(charset, overlap.charset);
 // duplicates already merged
 // src, dest
 merge(rhs.charset, overlap.charset);
 negated = false;
 rhs.negated = false;
 swap(charset, rhs.charset);
 normalise();
 overlap.normalise();
 rhs.normalise();
 }
 else if (!overlap.charset.length == 0)
 {
 normalise();
 overlap.normalise();
 rhs.normalise();
 }
 }
 }

 void intersectDiffTypes(ref BasicStringToken rhs,
 ref BasicStringToken overlap)
 {
 if (any())
 {
 intersectAny(rhs, overlap);
 }
 else if (negated)
 {
 intersectNegated(rhs, overlap);
 }
 

Re: Errors in TDPL

2010-06-22 Thread biozic

Le 22/06/10 15:53, Walter Bright a écrit :

biozic wrote:

Le 22/06/10 10:54, Walter Bright a écrit :

Andrei Alexandrescu wrote:

On 06/21/2010 08:47 PM, Jonathan M Davis wrote:

On page 82 of TDPL, it's talking about try/catch/finally statements,
and it
says that all controlled statement must be block statements; that is
they
must be enclosed with braces. However, dmd does not seem to require
that
try/catch/finally blocks have braces, which is what I would expect
that
sentence to mean. C++ has that restriction for reasons that I don't
understand, but as far as I can tell, D does not - certainly dmd
doesn't
appear to require it. Is the statement correct but refers to
something else,
or is it in error?

- Jonathan M Davis


That's a surprise to me. Walter, is that intentional?


They do not require braces, they just require that the controlling
statement not be a single ;. In the grammar, this is a ScopeStatement,
which is a NonEmptyStatement or a BlockStatement.


http://www.digitalmars.com/d/2.0/statement.html#ScopeStatement


Not always: http://d.puremagic.com/issues/show_bug.cgi?id=4024


Bugs in the compiler aren't errors in TDPL!


I totally agree. I was saying that the requirement for braces was not 
always intentional :S


Re: enforce()?

2010-06-22 Thread Sean Kelly
Walter Bright Wrote:

 Sean Kelly wrote:
  Regarding DbC, I can't say that I've ever worked on a system where lives 
  hung
  in the balance (an admittedly extreme example of where DbC is useful),
 
 I have, and here's how it's done:
 
 http://www.drdobbs.com/blog/archives/2009/10/safe_systems_fr.html
 
 http://www.drdobbs.com/blog/archives/2009/11/designing_safe.html
 
 I really wish this was more widely known in the software engineering 
 business. 
 It's frustrating to see it relearned the hard way, over and over.
 
 And not just the software business, I saw a technical overview of the BP oil 
 spill failure, and the rig design violated just about every principle of safe 
 system design.

A coworker of mine knows a guy who had workers on that rig and told me this 
story the other day.  Apparently, there's a system on the drill that when a 
failure occurs a cap drops over the hole and shears the drill.  The BP rig was 
drilling unusually deep though, and as a result the drill had to be incredibly 
hard.  For this and other reasons, the safety system was estimated to have a 
70% failure rate.  Furthermore, the rig was known to be on the verge of 
failure.  He implored the BP folks to shut it down, but they refused so in 
desperation he hired people to fly his team off the rig, fearing for their 
safety.  The rig failed a few hours after his team was evacuated.

While I've never worked on systems where lives hang in the balance, I have 
worked on systems where 100% uptime is required.  I favor the Erlang approach 
where a system is a web of interconnected, redundant processes that terminate 
on errors.  I've found this design an extremely hard sell in the internet 
server world though.  The design takes more planning and people are in too much 
of a hurry.


Re: Latest string_token Code

2010-06-22 Thread Ben Hanson
== Quote from Rory McGuire (rmcgu...@neonova.co.za)'s article
 On Tue, 22 Jun 2010 15:31:14 +0200, Ben Hanson ben.han...@tfbplc.co.uk
 wrote:
  == Quote from Rory McGuire (rmcgu...@neonova.co.za)'s article
  On Tue, 22 Jun 2010 15:13:06 +0200, Ben Hanson ben.han...@tfbplc.co.uk
  wrote:
   Here's the latest with naming convention (hopefully) followed. I've
   implemented my
   own squeeze() function and used sizeof in the memmove calls.
  
   How can I specify wide strings for the literals?
  
   Thanks,
  
   Ben
  
   module main;
  
   import std.algorithm;
   import std.array;
   import std.c.string;
   import std.string;
  
   import std.stdio;
  
   template regex(CharT)
   {
   struct BasicStringToken
   {
   bool negated = false;
   CharT[] charset;
   enum size_t MAX_CHARS = CharT.max + 1;
   enum size_t START_CHAR = cast(CharT) 0x80  0 ? 0x80 : 0;
  
   this(const bool negated_, ref CharT[] charset_)
   {
   negated = negated_;
   charset = charset_;
   }
  
   void removeDuplicates()
   {
   charset.sort;
   squeeze(charset);
   }
  
   void normalise()
   {
   if (charset.length == MAX_CHARS)
   {
   negated = !negated;
   charset.clear();
   }
   else if (charset.length  MAX_CHARS / 2)
   {
   negate();
   }
   }
  
   void negate()
   {
   CharT curr_char = START_CHAR;
   CharT[] temp;
   CharT *ptr = cast(CharT *) 0;
   CharT *curr = charset.ptr;
   CharT *end = curr + charset.length;
   size_t i = 0;
  
   negated = !negated;
   temp.length = MAX_CHARS - charset.length;
   ptr = temp.ptr;
  
   while (curr  end)
   {
   while (*curr  curr_char)
   {
   *ptr = curr_char;
   ++ptr;
   ++curr_char;
   ++i;
   }
  
   ++curr_char;
   ++curr;
   ++i;
   }
  
   for (; i  MAX_CHARS; ++i)
   {
   *ptr = curr_char;
   ++ptr;
   ++curr_char;
   }
  
   charset = temp;
   }
  
   bool empty()
   {
   return charset.length == 0  !negated;
   }
  
   bool any()
   {
   return charset.length == 0  negated;
   }
  
   void clear()
   {
   negated = false;
   charset.length = 0;
   }
  
   void intersect(ref BasicStringToken rhs,
   ref BasicStringToken overlap)
   {
   if ((any()  rhs.any()) || (negated == rhs.negated 
   !any()  !rhs.any()))
   {
   intersectSameTypes(rhs, overlap);
   }
   else
   {
   intersectDiffTypes(rhs, overlap);
   }
   }
  
   private:
   void intersectSameTypes(ref BasicStringToken rhs,
   ref BasicStringToken overlap)
   {
   if (any())
   {
   clear();
   overlap.negated = true;
   rhs.clear();
   }
   else
   {
   CharT *iter = charset.ptr;
   CharT *end = iter + charset.length;
   CharT *rhs_iter = rhs.charset.ptr;
   CharT *rhs_end = rhs_iter + rhs.charset.length;
  
   overlap.negated = negated;
  
   while (iter != end  rhs_iter != rhs_end)
   {
   if (*iter  *rhs_iter)
   {
   ++iter;
   }
   else if (*iter  *rhs_iter)
   {
   ++rhs_iter;
   }
   else
   {
   overlap.charset ~= *iter;
   memmove(iter, iter + 1, (charset.ptr +
   charset.length - iter) * CharT.sizeof);
   --end;
   charset.length -= 1;
   memmove(rhs_iter, rhs_iter + 1, (rhs.charset.ptr +
   rhs.charset.length - rhs_iter) *
  CharT.sizeof);
   --rhs_end;
   rhs.charset.length -= 1;
   }
   }
  
   if (negated)
   {
   // duplicates already merged
   // src, dest
   merge(charset, overlap.charset);
   // duplicates already merged
   // src, dest
   merge(rhs.charset, overlap.charset);
   negated = false;
   rhs.negated = false;
   swap(charset, rhs.charset);
   normalise();
   overlap.normalise();
   rhs.normalise();
   }
   else if (!overlap.charset.length == 0)
   {

Re: Improving std.regex(p)

2010-06-22 Thread David Gileadi
== Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s 
article#63275;
 scregexp includes the following requirement within the license:
 Redistributions in binary form must reproduce the above copyright
 notice, this list of conditions and the following disclaimer in the
 documentation and/or other materials provided with the distribution.
 That would need to be changed before inclusion in Phobos. It looks like
 there are three people in the copyright notice: Walter Bright, Marton
 Papp, and yidabu. Does anyone know Marton's email address?
 Andrei

Since I didn't see someone else reply, back when he announced the code he used
ante...@freemail.hu.

Google also turned up http://www.equinoxbase.com/. I'm not sure it's the same
fellow, but the page has his name, mentions D and has a contact form.  You could
also try PMing him at dsource: http://www.dsource.org/forums/profile.php?
mode=viewprofileu=1513


Re: This just in: authorless TDPL becomes collector's edition

2010-06-22 Thread Lutger
Andrei Alexandrescu wrote:

 Due to a pretty odd mistake at the printer, the first 1000 copies of
 TDPL will not have the name of the author on their cover. (The name
 still appears on the back cover and the spine.)
 
 The history of printing is rife with rare printing mistakes that have
 become collector's editions. Preorder now to be among the first 1000
 readers who get the authorless TDPL edition.
 
 
 Andrei

Just got my authorless copy from the local bookstore, they have several more of 
those in stock at their little C++ corner :) I'm looking forward to reading it. 
 


Re: enforce()?

2010-06-22 Thread Sean Kelly
Sean Kelly Wrote:
 
 While I've never worked on systems where lives hang in the balance, I have 
 worked on systems where 100% uptime is required.  I favor the Erlang approach 
 where a system is a web of interconnected, redundant processes that terminate 
 on errors.  I've found this design an extremely hard sell in the internet 
 server world though.  The design takes more planning and people are in too 
 much of a hurry.

I should add that I'm hoping the message passing model in D will help encourage 
reliable system design.  With thread isolation it should be pretty easy to move 
parts of a program into separate processes as need dictates.


Re: Latest string_token Code

2010-06-22 Thread Rory McGuire
On Tue, 22 Jun 2010 16:37:38 +0200, Ben Hanson ben.han...@tfbplc.co.uk  
wrote:



== Quote from Rory McGuire (rmcgu...@neonova.co.za)'s article

On Tue, 22 Jun 2010 15:31:14 +0200, Ben Hanson ben.han...@tfbplc.co.uk
wrote:
 == Quote from Rory McGuire (rmcgu...@neonova.co.za)'s article
 On Tue, 22 Jun 2010 15:13:06 +0200, Ben Hanson  
ben.han...@tfbplc.co.uk

 wrote:
  Here's the latest with naming convention (hopefully) followed. I've
  implemented my
  own squeeze() function and used sizeof in the memmove calls.
 
  How can I specify wide strings for the literals?
 
  Thanks,
 
  Ben
 
  module main;
 
  import std.algorithm;
  import std.array;
  import std.c.string;
  import std.string;
 
  import std.stdio;
 
  template regex(CharT)
  {
  struct BasicStringToken
  {
  bool negated = false;
  CharT[] charset;
  enum size_t MAX_CHARS = CharT.max + 1;
  enum size_t START_CHAR = cast(CharT) 0x80  0 ? 0x80 : 0;
 
  this(const bool negated_, ref CharT[] charset_)
  {
  negated = negated_;
  charset = charset_;
  }
 
  void removeDuplicates()
  {
  charset.sort;
  squeeze(charset);
  }
 
  void normalise()
  {
  if (charset.length == MAX_CHARS)
  {
  negated = !negated;
  charset.clear();
  }
  else if (charset.length  MAX_CHARS / 2)
  {
  negate();
  }
  }
 
  void negate()
  {
  CharT curr_char = START_CHAR;
  CharT[] temp;
  CharT *ptr = cast(CharT *) 0;
  CharT *curr = charset.ptr;
  CharT *end = curr + charset.length;
  size_t i = 0;
 
  negated = !negated;
  temp.length = MAX_CHARS - charset.length;
  ptr = temp.ptr;
 
  while (curr  end)
  {
  while (*curr  curr_char)
  {
  *ptr = curr_char;
  ++ptr;
  ++curr_char;
  ++i;
  }
 
  ++curr_char;
  ++curr;
  ++i;
  }
 
  for (; i  MAX_CHARS; ++i)
  {
  *ptr = curr_char;
  ++ptr;
  ++curr_char;
  }
 
  charset = temp;
  }
 
  bool empty()
  {
  return charset.length == 0  !negated;
  }
 
  bool any()
  {
  return charset.length == 0  negated;
  }
 
  void clear()
  {
  negated = false;
  charset.length = 0;
  }
 
  void intersect(ref BasicStringToken rhs,
  ref BasicStringToken overlap)
  {
  if ((any()  rhs.any()) || (negated == rhs.negated 
  !any()  !rhs.any()))
  {
  intersectSameTypes(rhs, overlap);
  }
  else
  {
  intersectDiffTypes(rhs, overlap);
  }
  }
 
  private:
  void intersectSameTypes(ref BasicStringToken rhs,
  ref BasicStringToken overlap)
  {
  if (any())
  {
  clear();
  overlap.negated = true;
  rhs.clear();
  }
  else
  {
  CharT *iter = charset.ptr;
  CharT *end = iter + charset.length;
  CharT *rhs_iter = rhs.charset.ptr;
  CharT *rhs_end = rhs_iter + rhs.charset.length;
 
  overlap.negated = negated;
 
  while (iter != end  rhs_iter != rhs_end)
  {
  if (*iter  *rhs_iter)
  {
  ++iter;
  }
  else if (*iter  *rhs_iter)
  {
  ++rhs_iter;
  }
  else
  {
  overlap.charset ~= *iter;
  memmove(iter, iter + 1, (charset.ptr +
  charset.length - iter) * CharT.sizeof);
  --end;
  charset.length -= 1;
  memmove(rhs_iter, rhs_iter + 1,  
(rhs.charset.ptr +

  rhs.charset.length - rhs_iter) *
 CharT.sizeof);
  --rhs_end;
  rhs.charset.length -= 1;
  }
  }
 
  if (negated)
  {
  // duplicates already merged
  // src, dest
  merge(charset, overlap.charset);
  // duplicates already merged
  // src, dest
  merge(rhs.charset, overlap.charset);
  negated = false;
  rhs.negated = false;
  swap(charset, rhs.charset);
  normalise();
  overlap.normalise();
  rhs.normalise();
  }
  else if (!overlap.charset.length == 0)
  {
  normalise();
  overlap.normalise();
  

Re: Latest string_token Code

2010-06-22 Thread Andrei Alexandrescu

On 06/22/2010 08:13 AM, Ben Hanson wrote:

Here's the latest with naming convention (hopefully) followed. I've implemented 
my
own squeeze() function and used sizeof in the memmove calls.


I suggest you to look into using the range primitives (empty, front, 
back, popFront, and popBack) with strings of any width. Your code 
assumes that all characters have the same width and therefore will 
behave erratically on UTF-8 and UTF-16 encodings.


In the particular case of squeeze(), you may want to use uniq instead, 
which works on any forward range and will therefore decode characters 
properly:


http://www.digitalmars.com/d/2.0/phobos/std_algorithm.html#uniq


Andrei


Re: Latest string_token Code

2010-06-22 Thread Ben Hanson
== Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s article
 On 06/22/2010 08:13 AM, Ben Hanson wrote:
  Here's the latest with naming convention (hopefully) followed. I've 
  implemented my
  own squeeze() function and used sizeof in the memmove calls.
 I suggest you to look into using the range primitives (empty, front,
 back, popFront, and popBack) with strings of any width. Your code
 assumes that all characters have the same width and therefore will
 behave erratically on UTF-8 and UTF-16 encodings.
 In the particular case of squeeze(), you may want to use uniq instead,
 which works on any forward range and will therefore decode characters
 properly:
 http://www.digitalmars.com/d/2.0/phobos/std_algorithm.html#uniq
 Andrei

OK, thanks.

Don't forget these are regular expressions though. I was wondering whether 
people
really want to pass regular expressions UTF encoded, but I suppose it could
happen. It's certainly a good idea to get used to using UTF compatible functions
anyway.

Is there is any support for Unicode continuation characters yet? Do you agree 
that
(ideally) Unicode text should be normalised before searching?

Regards,

Ben


Re: Feature request: Shared receive for all waitable objects

2010-06-22 Thread Sean Kelly
Phil Deets pjdee...@gmail.com wrote:
 http://d.puremagic.com/issues/show_bug.cgi?id=4365
 
 It would be nice to be able to wait for either socket data or a 
 cross-thread message. I've filed a bug with the request. I'm just
 posting  here in case anyone wants to vote on the bug or in case this
 post will  spur discussion which will cause the feature to be added
 sooner.

I'd like it too. But first I think the socket API in Phobos needs an
overhaul.   Also, waiting on both is really just a matter of having the
socket thread bundle incoming data into messages and sending it to
whoever, so that bit is pretty easy even for the user to do.


Re: enforce()?

2010-06-22 Thread Sean Kelly
Simen kjaeraas simen.kja...@gmail.com wrote:
 BCS n...@anon.com wrote:
 I think that for such situations you should ship a debug and release
 version of the DLL.
 This way you don't sacrifice performance when the user doesn't want
   to
 be
 held by the hand.
 
 Until you can show me a perf problem, I don't see any point in doing 
   that. (OTOH, deep structure validation, or anything else slower
   than   O(1), is another thing all together)
 
 Also, if you do have two different versions, I'll bet you ready money
 someone will program only the release version, because that's the
 version the users will have, the debug version is slow or whatever
 other inane excuse their minds are capable of coming up with.

What I've done with druntime is build checked and unchecked versions.  I
don't think it makes sense to ship a debug version of a library because
that's for debugging the library, not user code. I'll admit that I like
having debug symbols in place though, just not the debug tests
themselves. It's occasionally nice to not have a trace vanish just
because it passes through library code.


Re: Errors in TDPL

2010-06-22 Thread Byron Heads
On pg. 12 you define a recursive binary search, you forgot to pass value 
on the recursive call.

-B



Re: enforce()?

2010-06-22 Thread Lutger
Simen kjaeraas wrote:

 BCS n...@anon.com wrote:
 I think that for such situations you should ship a debug and release
 version of the DLL.
 This way you don't sacrifice performance when the user doesn't want to
 be
 held by the hand.

 Until you can show me a perf problem, I don't see any point in doing
 that. (OTOH, deep structure validation, or anything else slower than
 O(1), is another thing all together)
 
 Also, if you do have two different versions, I'll bet you ready money
 someone will program only the release version, because that's the
 version the users will have, the debug version is slow or whatever
 other inane excuse their minds are capable of coming up with.
 

Naturally, debug is for debugging, not shipping. Instead one could make three 
versions:
- debug  
- release
- unsafe

Or rather let the user compile unsafe themselves if you can distribute the 
source code. 

I am sure most inane users (like me) will choose release.


Re: Floating point not loaded

2010-06-22 Thread Robert Jacques

On Tue, 22 Jun 2010 04:04:03 -0400, Clemens eriatark...@gmail.com wrote:


Clemens Wrote:

I have a stupid problem linking D with C. This is with D 1.062, haven't  
tried D2. So say I have two files:


-- cfmt.c 

#include string.h

char* myfmt(double x)
{
static char buf[40];
sprintf(buf, %f, x);
return buf;
}

--- test.d 

extern(C) char* myfmt(double x);

void main()
{
myfmt(42.3);
}

---

and I compile and link them as follows:

 dmc -c cfmt.c
 dmd test.d cfmt.obj
 test.exe

I get the runtime error Floating point not loaded. No exception or  
anything, the executable just terminates with that message on the  
terminal. I found a short paragraph about that runtime error on

http://www.digitalmars.com/ctg/runtime.html
but it wasn't too helpful; a quick grep showed me that _fltused occurs  
in both cfmt.obj and test.obj.


Anyone seen this before? What can I do? I'm pretty sure this used to  
work with an older version. The actual real-world use case is linking  
to Lua, which bombs out with the same message once you use the string  
concatenation operator with a numeric argument. I used the Lua binding  
from dsource which comes with a precompiled library, and just to be  
sure I then compiled my own version of Lua with dmc; to no avail.


Clemens


FWIW, I found a workaround to this: if I specify to link with snn.lib  
explicitly on the command line, then everything seems to work. I'm a bit  
surprised since I thought that snn.lib is pulled in automatically. Is  
this a bug in DMD, in Optlink, or by some strange twist of fate expected  
behavior?


Clemens


You always need to specify the libs you're linking too. This has always  
been the case. There is a pragma statement that tells the compiler to link  
a library, so you can specify the link in the code rather than the command  
line.


Re: readf anyone?

2010-06-22 Thread Ali Çehreli

Andrei Alexandrescu wrote:

Sorry! I've had the message TODO: implement readf for a good while 
emitted during Phobos builds. You read too fast :o). I'll implement it 
today. I actually have the code somewhere already. Apologies.


Will that work with any type like format does? There are unformat and 
formattedRead in format.d. Is FormatInfo a user serviceable part? :)


Could you please show an example on how to unformat any type.

It may already be in the book but I haven't gotten to that point yet. :)

Ali


Re: Floating point not loaded

2010-06-22 Thread Clemens
Robert Jacques Wrote:

 On Tue, 22 Jun 2010 04:04:03 -0400, Clemens eriatark...@gmail.com wrote:
 
  Clemens Wrote:
 
  I have a stupid problem linking D with C. This is with D 1.062, haven't  
  tried D2. So say I have two files:
 
  -- cfmt.c 
 
  #include string.h
 
  char* myfmt(double x)
  {
 static char buf[40];
 sprintf(buf, %f, x);
 return buf;
  }
 
  --- test.d 
 
  extern(C) char* myfmt(double x);
 
  void main()
  {
 myfmt(42.3);
  }
 
  ---
 
  and I compile and link them as follows:
 
   dmc -c cfmt.c
   dmd test.d cfmt.obj
   test.exe
 
  I get the runtime error Floating point not loaded. No exception or  
  anything, the executable just terminates with that message on the  
  terminal. I found a short paragraph about that runtime error on
  http://www.digitalmars.com/ctg/runtime.html
  but it wasn't too helpful; a quick grep showed me that _fltused occurs  
  in both cfmt.obj and test.obj.
 
  Anyone seen this before? What can I do? I'm pretty sure this used to  
  work with an older version. The actual real-world use case is linking  
  to Lua, which bombs out with the same message once you use the string  
  concatenation operator with a numeric argument. I used the Lua binding  
  from dsource which comes with a precompiled library, and just to be  
  sure I then compiled my own version of Lua with dmc; to no avail.
 
  Clemens
 
  FWIW, I found a workaround to this: if I specify to link with snn.lib  
  explicitly on the command line, then everything seems to work. I'm a bit  
  surprised since I thought that snn.lib is pulled in automatically. Is  
  this a bug in DMD, in Optlink, or by some strange twist of fate expected  
  behavior?
 
  Clemens
 
 You always need to specify the libs you're linking too. This has always  
 been the case. There is a pragma statement that tells the compiler to link  
 a library, so you can specify the link in the code rather than the command  
 line.

I do believe the case is different here since snn.lib is the Digital Mars C 
runtime library. I quote from http://www.digitalmars.com/d/1.0/dmd-windows.html:

 The programs must be linked with the D runtime library phobos.lib, followed 
 by the C runtime library snn.lib. This is done automatically as long as the 
 directories for the libraries are on the LIB environment variable path.

I have no reason to doubt that the paths are set up correctly since linking a 
D-only program works without problems.

Also note that this is a runtime error, not a compile- or link-time error.


Re: String Literal Docs

2010-06-22 Thread div0

On 20/06/2010 20:14, Nick Sabalausky wrote:

div0d...@users.sourceforge.net  wrote in message
news:hvlok6$1rf...@digitalmars.com...

On 20/06/2010 18:55, Nick Sabalausky wrote:

div0d...@users.sourceforge.net   wrote in message
news:hvkrsc$2r5...@digitalmars.com...


It says multiple of 2, not even number of digits.


multiple of 2 == even number

Even as in even vs odd


I also said 'To me that implies'. Please don't take what I said out of
context and be a smart arse about it. There's more than enough of that
goes on round here.



That wan't my intent, sorry if it came across that way. It sounded to me
like you were implying there was a difference between multiple of 2 and
even number. If that wasn't the case, then I guess I'm just not sure what
you were really getting at.




What I was getting at is that if you use the w suffix, then surely you 
would expect the number of hex digits to be a multiple of 4 not 2.


If there are only 6 digits what then? Are the missing one inferred to be 
0, is it a compile error, or something else?


Because of the use of the 2, I inferred from the spec that the suffixes 
were not supposed to be allowed. If it had said even number of digits, 
I'd have been more inclined to think that the suffixes are legal.


Either which way it just high lights that the spec isn't sufficiently clear.

--
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk


Re: Is there ANY chance we can fix the bitwise operator precedence rules?

2010-06-22 Thread Jeff Nowakowski

On 06/22/2010 08:39 AM, Don wrote:


I think you misunderstood. I was arguing that there is no association
between 'goto' and loops. People who use goto, use it for error
handling, not for looping. I was by no means advocating the use of goto
for error handling!


Oh good :) The looping part wasn't about goto, it was about the 
alternate proposal of reusing continue to mean fallthrough.


Re: Errors in TDPL

2010-06-22 Thread Andrei Alexandrescu

On 06/22/2010 11:16 AM, Byron Heads wrote:

On pg. 12 you define a recursive binary search, you forgot to pass value
on the recursive call.

-B


Saw the erratum you posted - thanks!

Andrei


Re: Floating point not loaded

2010-06-22 Thread Don

Clemens wrote:

Robert Jacques Wrote:


On Tue, 22 Jun 2010 04:04:03 -0400, Clemens eriatark...@gmail.com wrote:


Clemens Wrote:

I have a stupid problem linking D with C. This is with D 1.062, haven't  
tried D2. So say I have two files:


-- cfmt.c 

#include string.h

char* myfmt(double x)
{
static char buf[40];
sprintf(buf, %f, x);
return buf;
}

--- test.d 

extern(C) char* myfmt(double x);

void main()
{
myfmt(42.3);
}

---

and I compile and link them as follows:


dmc -c cfmt.c
dmd test.d cfmt.obj
test.exe
I get the runtime error Floating point not loaded. No exception or  
anything, the executable just terminates with that message on the  
terminal. I found a short paragraph about that runtime error on

http://www.digitalmars.com/ctg/runtime.html
but it wasn't too helpful; a quick grep showed me that _fltused occurs  
in both cfmt.obj and test.obj.


Anyone seen this before? What can I do? I'm pretty sure this used to  
work with an older version. The actual real-world use case is linking  
to Lua, which bombs out with the same message once you use the string  
concatenation operator with a numeric argument. I used the Lua binding  
from dsource which comes with a precompiled library, and just to be  
sure I then compiled my own version of Lua with dmc; to no avail.


Clemens
FWIW, I found a workaround to this: if I specify to link with snn.lib  
explicitly on the command line, then everything seems to work. I'm a bit  
surprised since I thought that snn.lib is pulled in automatically. Is  
this a bug in DMD, in Optlink, or by some strange twist of fate expected  
behavior?


Clemens
You always need to specify the libs you're linking too. This has always  
been the case. There is a pragma statement that tells the compiler to link  
a library, so you can specify the link in the code rather than the command  
line.


I do believe the case is different here since snn.lib is the Digital Mars C 
runtime library. I quote from http://www.digitalmars.com/d/1.0/dmd-windows.html:


The programs must be linked with the D runtime library phobos.lib, followed by 
the C runtime library snn.lib. This is done automatically as long as the 
directories for the libraries are on the LIB environment variable path.


I have no reason to doubt that the paths are set up correctly since linking a 
D-only program works without problems.

Also note that this is a runtime error, not a compile- or link-time error.


Sounds as though there might be two different versions of snn.lib? Maybe 
  it's getting the wrong one.


Re: Errors in TDPL

2010-06-22 Thread Bill Baxter
On Mon, Jun 21, 2010 at 3:39 PM, Andrei Alexandrescu
seewebsiteforem...@erdani.org wrote:
 On 06/21/2010 02:09 PM, Jonathan M Davis wrote:

 Okay. I am in no way trying to say anything negative about TDPL.

 [snip]

 You are being too kind about this :o). Of course we need an errata list. I
 was hoping I'd need to set it up later, but hey, that's a sign people
 actually are reading the book and care about keeping everything in check.

 I started an errata list in form of a community wiki at

 http://www.erdani.com/tdpl/errata

 and primed the errata with your report.

 Thanks very much! I'll see to it that future printings fix the issues in the
 errata list.

Will you fix all the god-awful puns too if we add those to the list?  :-)

Just kidding, I'm sure suffering through them helps build character or
something.

--bb


Re: Errors in TDPL

2010-06-22 Thread Andrei Alexandrescu

On 06/22/2010 01:45 PM, Bill Baxter wrote:

On Mon, Jun 21, 2010 at 3:39 PM, Andrei Alexandrescu
seewebsiteforem...@erdani.org  wrote:

On 06/21/2010 02:09 PM, Jonathan M Davis wrote:


Okay. I am in no way trying to say anything negative about TDPL.


[snip]

You are being too kind about this :o). Of course we need an errata list. I
was hoping I'd need to set it up later, but hey, that's a sign people
actually are reading the book and care about keeping everything in check.

I started an errata list in form of a community wiki at

http://www.erdani.com/tdpl/errata

and primed the errata with your report.

Thanks very much! I'll see to it that future printings fix the issues in the
errata list.


Will you fix all the god-awful puns too if we add those to the list?  :-)

Just kidding, I'm sure suffering through them helps build character or
something.


If my puns suck I sure want to know which!

Andrei


Re: Errors in TDPL

2010-06-22 Thread Graham Fawcett
On Tue, 22 Jun 2010 11:45:39 -0700, Bill Baxter wrote:

 On Mon, Jun 21, 2010 at 3:39 PM, Andrei Alexandrescu
 seewebsiteforem...@erdani.org wrote:
 On 06/21/2010 02:09 PM, Jonathan M Davis wrote:

 Okay. I am in no way trying to say anything negative about TDPL.

 [snip]

 You are being too kind about this :o). Of course we need an errata
 list. I was hoping I'd need to set it up later, but hey, that's a sign
 people actually are reading the book and care about keeping everything
 in check.

 I started an errata list in form of a community wiki at

 http://www.erdani.com/tdpl/errata

 and primed the errata with your report.

 Thanks very much! I'll see to it that future printings fix the issues
 in the errata list.
 
 Will you fix all the god-awful puns too if we add those to the list? 
 :-)
 
 Just kidding, I'm sure suffering through them helps build character or
 something.

Awful puns, you say? Now I have to buy a copy!

Graham


Re: Errors in TDPL

2010-06-22 Thread Jonathan M Davis
Bill Baxter wrote:

 On Mon, Jun 21, 2010 at 3:39 PM, Andrei Alexandrescu
 seewebsiteforem...@erdani.org wrote:
 On 06/21/2010 02:09 PM, Jonathan M Davis wrote:

 Okay. I am in no way trying to say anything negative about TDPL.

 [snip]

 You are being too kind about this :o). Of course we need an errata list.
 I was hoping I'd need to set it up later, but hey, that's a sign people
 actually are reading the book and care about keeping everything in check.

 I started an errata list in form of a community wiki at

 http://www.erdani.com/tdpl/errata

 and primed the errata with your report.

 Thanks very much! I'll see to it that future printings fix the issues in
 the errata list.
 
 Will you fix all the god-awful puns too if we add those to the list?  :-)
 
 Just kidding, I'm sure suffering through them helps build character or
 something.
 
 --bb

Aw. Those were awesome. Of course, I love puns, so I'm not about to complain 
about them unless they're really bad, and Andrei's were good.

- Jonathan M Davis


Re: Errors in TDPL

2010-06-22 Thread Bill Baxter
On Tue, Jun 22, 2010 at 11:52 AM, Andrei Alexandrescu
seewebsiteforem...@erdani.org wrote:
 On 06/22/2010 01:45 PM, Bill Baxter wrote:

 On Mon, Jun 21, 2010 at 3:39 PM, Andrei Alexandrescu
 seewebsiteforem...@erdani.org  wrote:

 On 06/21/2010 02:09 PM, Jonathan M Davis wrote:

 Okay. I am in no way trying to say anything negative about TDPL.

 [snip]

 You are being too kind about this :o). Of course we need an errata list.
 I
 was hoping I'd need to set it up later, but hey, that's a sign people
 actually are reading the book and care about keeping everything in check.

 I started an errata list in form of a community wiki at

 http://www.erdani.com/tdpl/errata

 and primed the errata with your report.

 Thanks very much! I'll see to it that future printings fix the issues in
 the
 errata list.

 Will you fix all the god-awful puns too if we add those to the list?  :-)

 Just kidding, I'm sure suffering through them helps build character or
 something.

 If my puns suck I sure want to know which!

 Andrei

They're fine.  I'm just kidding.

A pun is the lowest form of humor--
  if you didn't think of it first. -- Oscar Levant

--bb


Re: This just in: authorless TDPL becomes collector's edition

2010-06-22 Thread Danny Wilson

I got two collectors editions. I'll sell one for 1000$ :-D


On Tue, 22 Jun 2010 13:10:00 +0200, Tyro[a.c.edwards] no.s...@home.com  
wrote:



good for you, sucks for me though, I didn't get a collector's edition
and I ordered my copy back in over six months ago.


Re: Latest string_token Code

2010-06-22 Thread bearophile
Ben Hanson:

Even if you are an expert C++ programmer, I can express few more comments about 
your code, to show how to program in D (here I comment only the first example 
of each thing. More cases can follow).

--

You can write this:

template regex(CharT)
{
struct BasicStringToken
{

Like this:

template regex(CharT)
{
struct BasicStringToken
{

--

In this part:

void negate()
{
CharT curr_char = START_CHAR;
CharT[] temp;
CharT *ptr = cast(CharT *) 0;


This is closer to normal D code, because in D there is null, and in D the * 
of pointer definitions is better written on the left, because it's part of the 
type:

void negate()
{
CharT curr_char = START_CHAR;
CharT[] temp;
CharT* ptr = null;


But the idiomatic D code is this because pointers are automatically initialized 
to null, and nornally in D variable names are camelCase with a starting 
lowercase (sometimes I'd like to use underscores, but this is the D style. 
Constant names can contain underscores in D, I presume):

void negate()
{
CharT currChar = START_CHAR;
CharT[] temp;
CharT* ptr;

--

This line:

else if (!overlap.charset.length == 0)

I don't like it a lot, maybe this is better:

else if (overlap.charset.length)

--

This code:

else if (negated)
{
intersectNegated(rhs, overlap);
}
else // negated == false
{
intersectCharset(rhs, overlap);
}


There is no need of that comment, never add useless noise to the code:

else if (negated)
{
intersectNegated(rhs, overlap);
}
else
{
intersectCharset(rhs, overlap);
}

--

I see that in your code you lot of pointers. Pointers can be used in D, but I 
suggest you to use them only when necessary. Maybe some usage of pointers can 
be replaced by normal array indexes, that are safer too (because in D in 
nonrelease mode array bounds are tested).

For some situations I have created in D2 a safer pointer that in release mode 
is as efficient as a pointer but in nonrelease mode asserts if you make it step 
out of a pre-specified memory interval. I don't think lot of people here has 
appreciated it, but I have used it to catch some of my pointer-releated bugs.

Bye,
bearophile


Re: Floating point not loaded

2010-06-22 Thread Clemens
Don Wrote:

 Clemens wrote:
  Robert Jacques Wrote:
  
  On Tue, 22 Jun 2010 04:04:03 -0400, Clemens eriatark...@gmail.com wrote:
 
  Clemens Wrote:
 
  I have a stupid problem linking D with C. This is with D 1.062, haven't  
  tried D2. So say I have two files:
 
  -- cfmt.c 
 
  #include string.h
 
  char* myfmt(double x)
  {
   static char buf[40];
   sprintf(buf, %f, x);
   return buf;
  }
 
  --- test.d 
 
  extern(C) char* myfmt(double x);
 
  void main()
  {
   myfmt(42.3);
  }
 
  ---
 
  and I compile and link them as follows:
 
  dmc -c cfmt.c
  dmd test.d cfmt.obj
  test.exe
  I get the runtime error Floating point not loaded. No exception or  
  anything, the executable just terminates with that message on the  
  terminal. I found a short paragraph about that runtime error on
  http://www.digitalmars.com/ctg/runtime.html
  but it wasn't too helpful; a quick grep showed me that _fltused occurs  
  in both cfmt.obj and test.obj.
 
  Anyone seen this before? What can I do? I'm pretty sure this used to  
  work with an older version. The actual real-world use case is linking  
  to Lua, which bombs out with the same message once you use the string  
  concatenation operator with a numeric argument. I used the Lua binding  
  from dsource which comes with a precompiled library, and just to be  
  sure I then compiled my own version of Lua with dmc; to no avail.
 
  Clemens
  FWIW, I found a workaround to this: if I specify to link with snn.lib  
  explicitly on the command line, then everything seems to work. I'm a bit  
  surprised since I thought that snn.lib is pulled in automatically. Is  
  this a bug in DMD, in Optlink, or by some strange twist of fate expected  
  behavior?
 
  Clemens
  You always need to specify the libs you're linking too. This has always  
  been the case. There is a pragma statement that tells the compiler to link 
   
  a library, so you can specify the link in the code rather than the command 
   
  line.
  
  I do believe the case is different here since snn.lib is the Digital Mars C 
  runtime library. I quote from 
  http://www.digitalmars.com/d/1.0/dmd-windows.html:
  
  The programs must be linked with the D runtime library phobos.lib, 
  followed by the C runtime library snn.lib. This is done automatically as 
  long as the directories for the libraries are on the LIB environment 
  variable path.
  
  I have no reason to doubt that the paths are set up correctly since linking 
  a D-only program works without problems.
  
  Also note that this is a runtime error, not a compile- or link-time error.
 
 Sounds as though there might be two different versions of snn.lib? Maybe 
it's getting the wrong one.

Funnily enough, the snn.lib from the DMC zip and the one from the DMD zip do 
slightly differ, but the sizes are almost the same, so the difference probably 
isn't huge. Regardless, I now completely removed the LIB= key from my sc.ini so 
that I need to specify all libraries by hand, and as soon as I mention one of 
the snn.lib files on the command line, no matter the DMC or the DMD one, 
everything works flawlessly. If I don't mention it explicitly but have it on 
the LIB path, then the program links fine, but I get the runtime error. I'm at 
a loss as to what's wrong here.

Can anyone reproduce this bug? I tried it on Linux and it works there, this is 
strictly a Windows issue.


Re: This just in: authorless TDPL becomes collector's edition

2010-06-22 Thread Jacob Carlborg

On 2010-06-22 14:51, Andrei Alexandrescu wrote:

On 06/22/2010 07:45 AM, Jacob Carlborg wrote:

On 2010-06-21 21:23, Mike James wrote:

Got my collectors item delivered today from Amazon UK. Looks good. I
like
the bonus of being able to download a PDF version of TDPL.

Thanks for all the hard work Andrei.

-=mike=-

Andrei Alexandrescuseewebsiteforem...@erdani.org wrote in message
news:hu3hq6$2f0...@digitalmars.com...

Due to a pretty odd mistake at the printer, the first 1000 copies of
TDPL
will not have the name of the author on their cover. (The name still
appears on the back cover and the spine.)

The history of printing is rife with rare printing mistakes that have
become collector's editions. Preorder now to be among the first 1000
readers who get the authorless TDPL edition.


Andrei


What happened to the nice looking PDF file we saw previews on, that one
with syntax highlighting and a green background in the code example?


That's the iPad edition :o).

Now seriously, what happens is that what you see is exactly what went to
the printer. I can configure colors for a color edition, but for now the
publisher asked me for black and white.

Andrei


That's too bad. I can understand that the publisher want it in black and 
withe but the PDF, it would have been nice to the PDF in color.


--
/Jacob Carlborg


Re: This just in: authorless TDPL becomes collector's edition

2010-06-22 Thread Mike James
Jacob Carlborg d...@me.com wrote in message 
news:hvr503$287...@digitalmars.com...
 On 2010-06-22 14:51, Andrei Alexandrescu wrote:
 On 06/22/2010 07:45 AM, Jacob Carlborg wrote:
 On 2010-06-21 21:23, Mike James wrote:
 Got my collectors item delivered today from Amazon UK. Looks good. I
 like
 the bonus of being able to download a PDF version of TDPL.

 Thanks for all the hard work Andrei.

 -=mike=-

 Andrei Alexandrescuseewebsiteforem...@erdani.org wrote in message
 news:hu3hq6$2f0...@digitalmars.com...
 Due to a pretty odd mistake at the printer, the first 1000 copies of
 TDPL
 will not have the name of the author on their cover. (The name still
 appears on the back cover and the spine.)

 The history of printing is rife with rare printing mistakes that have
 become collector's editions. Preorder now to be among the first 1000
 readers who get the authorless TDPL edition.


 Andrei

 What happened to the nice looking PDF file we saw previews on, that one
 with syntax highlighting and a green background in the code example?

 That's the iPad edition :o).

 Now seriously, what happens is that what you see is exactly what went to
 the printer. I can configure colors for a color edition, but for now the
 publisher asked me for black and white.

 Andrei

 That's too bad. I can understand that the publisher want it in black and 
 withe but the PDF, it would have been nice to the PDF in color.

 -- 
 /Jacob Carlborg

Maybe the color PDF will be another collectors item ;-)

-=mike=-




Re: readf anyone?

2010-06-22 Thread Tomek Sowiński

double q;
readf(%s, q);


Why it takes a pointer, not a ref?


Re: DMD Backend Long-term

2010-06-22 Thread BCS

Hello Robert,


On Mon, 21 Jun 2010 23:55:48 -0400, BCS n...@anon.com wrote:


Hello Leandro,


Nick Sabalausky, el 21 de junio a las 13:40 me escribiste:


Eldar Insafutdinov e.insafutdi...@gmail.com wrote in message
news:hvo49k$1uk...@digitalmars.com...


In the end, Windows is the most popular
OS despite our personal preferences, and it's worth spending some
time for
it.

I wish someone could convince LLVM of that...


Maybe it should be the other way around. Someone who cares about
Windows should give some love to LLVM =)


How hard are the problems? I have zero experience in LLVM and very
little in compiler work but if the problems could be attacked without
to  much ramp-up I'd be interested in looking into them.


The main issue (as I understand it) is adding windows style structured
exception handling to LLVM.



After a little digging it seems that LLVM legally CAN'T add SEH as MS has 
it under patent. I'm still digging to figure out how it could be patented 
without making SEH an irrelevant technology.


--
... IXOYE





Re: readf anyone?

2010-06-22 Thread Steven Schveighoffer

On Tue, 22 Jun 2010 16:42:46 -0400, Tomek Sowiński j...@ask.me wrote:


double q;
readf(%s, q);


Why it takes a pointer, not a ref?


Probably because it's variadic, so the compiler will pass by value if you  
don't use a pointer.


-Steve


Re: Latest string_token Code

2010-06-22 Thread Ben Hanson
== Quote from bearophile (bearophileh...@lycos.com)'s article
 Ben Hanson:
 Even if you are an expert C++ programmer, I can express few more comments 
 about
your code, to show how to program in D (here I comment only the first example of
each thing. More cases can follow).

It's hard to be an expert in C++ these days, particularly when posting to a 
group
frequented by Andrei! :-D

 --
 You can write this:
 template regex(CharT)
 {
 struct BasicStringToken
 {
 Like this:
 template regex(CharT)
 {
 struct BasicStringToken
 {
 --
 In this part:
 void negate()
 {
 CharT curr_char = START_CHAR;
 CharT[] temp;
 CharT *ptr = cast(CharT *) 0;
 This is closer to normal D code, because in D there is null, and in D the * 
 of
pointer definitions is better written on the left, because it's part of the 
type:
 void negate()
 {
 CharT curr_char = START_CHAR;
 CharT[] temp;
 CharT* ptr = null;
 But the idiomatic D code is this because pointers are automatically 
 initialized
to null, and nornally in D variable names are camelCase with a starting 
lowercase
(sometimes I'd like to use underscores, but this is the D style. Constant names
can contain underscores in D, I presume):
 void negate()
 {
 CharT currChar = START_CHAR;
 CharT[] temp;
 CharT* ptr;
 --

I forgot about auto initialisation in D. D'oh!

 This line:
 else if (!overlap.charset.length == 0)
 I don't like it a lot, maybe this is better:
 else if (overlap.charset.length)

This is just a bug. Should be:
 else if (!overlap.charset.length)

 --
 This code:
 else if (negated)
 {
 intersectNegated(rhs, overlap);
 }
 else // negated == false
 {
 intersectCharset(rhs, overlap);
 }
 There is no need of that comment, never add useless noise to the code:
 else if (negated)
 {
 intersectNegated(rhs, overlap);
 }
 else
 {
 intersectCharset(rhs, overlap);
 }

Those comments were deliberate as a 'yes I do mean that', but I've removed them
anyway.

 --
 I see that in your code you lot of pointers. Pointers can be used in D, but I
suggest you to use them only when necessary. Maybe some usage of pointers can be
replaced by normal array indexes, that are safer too (because in D in nonrelease
mode array bounds are tested).
 For some situations I have created in D2 a safer pointer that in release 
 mode
is as efficient as a pointer but in nonrelease mode asserts if you make it step
out of a pre-specified memory interval. I don't think lot of people here has
appreciated it, but I have used it to catch some of my pointer-releated bugs.
 Bye,
 bearophile

All the code for this library needs to absolutely as fast as it can be. As it
turns out, by intersecting regex charsets once in the code then it won't take 
that
many cycles, but the only question I have is:

Will the optimiser create as fast code if you use indexes compared to pointers?

Updated code follows.

Thanks,

Ben

module main;

import std.algorithm;
import std.array;
import std.c.string;
import std.string;

import std.stdio;

template regex(CharT)
{
struct BasicStringToken
{
bool negated = false;
CharT[] charset;
enum size_t MAX_CHARS = CharT.max + 1;
enum size_t START_CHAR = cast(CharT) 0x80  0 ? 0x80 : 0;

this(const bool negated_, ref CharT[] charset_)
{
negated = negated_;
charset = charset_;
}

void removeDuplicates()
{
charset.sort;
squeeze(charset);
}

void normalise()
{
if (charset.length == MAX_CHARS)
{
negated = !negated;
charset.clear();
}
else if (charset.length  MAX_CHARS / 2)
{
negate();
}
}

void negate()
{
CharT currChar = START_CHAR;
CharT[] temp;
CharT *ptr;
CharT *curr = charset.ptr;
CharT *end = curr + charset.length;
size_t i = 0;

negated = !negated;
temp.length = MAX_CHARS - charset.length;
ptr = temp.ptr;

while (curr  end)
{
while (*curr  currChar)
{
*ptr = currChar;
++ptr;
++currChar;
++i;
}

++currChar;
++curr;
++i;
}

for (; i  MAX_CHARS; ++i)
{
*ptr = currChar;
++ptr;
++currChar;
}

charset = temp;
}

bool empty()
{
return charset.length == 0  !negated;
}

bool any()
{
return charset.length == 0  negated;
}

void clear()
{
negated = false;
charset.length = 0;
}

void intersect(ref 

Re: Errors in TDPL

2010-06-22 Thread Jonathan M Davis
Andrei Alexandrescu wrote:

 On 06/21/2010 03:32 PM, Ellery Newcomer wrote:
 I was biting my tongue on the subject, but on page 73 the grammar for
 the do while loop has a semicolon at the end. AAH
 THERE IS NOOO SEMICOLON AT THE END.

 Wow. Sorry. This is a pet peeve of mine.
 
 Can't help that, sorry...
 
 Andrei

Well, while I, personally, would put a semicolon there (it feels naked to me 
without one), dmd doesn't actually seem to require it. But TDPL says that 
the semicolon is required. So, it does appear to be an error in the text. Of 
course, there's no helping his pet peeve regardless, but the semicolon 
doesn't appear to be required.

- Jonathan M Davis


Re: DMD Backend Long-term

2010-06-22 Thread Robert Jacques

On Tue, 22 Jun 2010 16:47:14 -0400, BCS n...@anon.com wrote:


Hello Robert,


On Mon, 21 Jun 2010 23:55:48 -0400, BCS n...@anon.com wrote:


Hello Leandro,


Nick Sabalausky, el 21 de junio a las 13:40 me escribiste:


Eldar Insafutdinov e.insafutdi...@gmail.com wrote in message
news:hvo49k$1uk...@digitalmars.com...


In the end, Windows is the most popular
OS despite our personal preferences, and it's worth spending some
time for
it.

I wish someone could convince LLVM of that...


Maybe it should be the other way around. Someone who cares about
Windows should give some love to LLVM =)


How hard are the problems? I have zero experience in LLVM and very
little in compiler work but if the problems could be attacked without
to  much ramp-up I'd be interested in looking into them.


The main issue (as I understand it) is adding windows style structured
exception handling to LLVM.



After a little digging it seems that LLVM legally CAN'T add SEH as MS  
has it under patent. I'm still digging to figure out how it could be  
patented without making SEH an irrelevant technology.




The patent seems to be Borlands's:
USPTO patent #5,628,016 Patent held by Borland on compiler support for SEH.
From a Wine wiki page: http://wiki.winehq.org/CompilerExceptionSupport

It does seem to expire on June 15, 2014, though and I assume DigitalMars  
has a license, so a LLVM fork is not unreasonable.


Re: Errors in TDPL

2010-06-22 Thread Andrei Alexandrescu

On 06/22/2010 04:14 PM, Jonathan M Davis wrote:

Andrei Alexandrescu wrote:


On 06/21/2010 03:32 PM, Ellery Newcomer wrote:

I was biting my tongue on the subject, but on page 73 the grammar for
the do while loop has a semicolon at the end. AAH
THERE IS NOOO SEMICOLON AT THE END.

Wow. Sorry. This is a pet peeve of mine.


Can't help that, sorry...

Andrei


Well, while I, personally, would put a semicolon there (it feels naked to me
without one), dmd doesn't actually seem to require it. But TDPL says that
the semicolon is required. So, it does appear to be an error in the text. Of
course, there's no helping his pet peeve regardless, but the semicolon
doesn't appear to be required.

- Jonathan M Davis


Walter, was that intentional? The grammar has no semicolon but the 
example does. That makes the example wrong because you agreed there is 
no solitary semicolon statement in D, and TDPL does mention that.


IMHO the semicolon makes for more robust code. Consider:

do
{
... lotsa code ...
}
while (fun(i))
++i;

A maintainer might see the while and conclude that ++i; was meant to be 
the loop, indent it, and call it a day. The absence of the semicolon 
thus created a contextual dependency on the presence of the do keyword 
upstream.


Walter, can we require a semicolon please?


Andrei


Re: Latest string_token Code

2010-06-22 Thread bearophile
Ben Hanson:
 Will the optimiser create as fast code if you use indexes compared to 
 pointers?

Do you mean the dmd optimizer or the llvm one?
LLVM is able to digest array indexes and pointers about equally efficiently. In 
one important case dmd seems to produce slower code with pointers compared to 
arrays :-)
In some situations it's better to use pointers because they allow a richer 
semantics, but in many situations arrays give better-looking (and a bit safer) 
code.
If you have some free time you can create an array-based version and compare 
their performance. Otherwise if your original C++ code uses pointers then maybe 
it's better to keep them, to avoid translation bugs. You need lot of care to 
translate code between two different languages, you need a strong rigour.

Another small thing I've seen in your code:

 template regex(CharT)
 {
 struct BasicStringToken
 {
...
 };
 }

D struct definitions don't need an ending semicolon, so it's better to not add 
it in D code.

Bye,
bearophile


Re: Review: std.msgpack

2010-06-22 Thread Jacob Carlborg

On 2010-06-22 04:39, Robert Jacques wrote:

On Mon, 21 Jun 2010 22:24:42 -0400, Masahiro Nakagawa
repeate...@gmail.com wrote:


On Sun, 20 Jun 2010 04:27:08 +0900, Jacob Carlborg d...@me.com wrote:


Serialization from base class was one of my goals when I implemented
Orange.


Good.


But you need to register a function for that, until D2 fixes the
getMembers method in TypeInfo_Class.


You reported this bug? I couldn't find closest bug in bugzilla.


The root bug is 1348: offTi property of TypeInfo return empty array.
offTi or offset typeinfo should contain an array of offsets and their
typeinfo, i.e. runtime reflection. There are also a bunch of other
typeinfo bugs in bugzilla.


Like the missing const declaration on the name method in 
TypeInfo_Member (or what the name of the class is).




Masahiro



--
/Jacob Carlborg


Re: Errors in TDPL

2010-06-22 Thread bearophile
Andrei Alexandrescu:
you agreed there is no solitary semicolon statement in D,

This compiles, is this a solitary semicolon statement?

void main() {
goto FOO;
FOO:;
}


 Walter, can we require a semicolon please?

+1

Bye,
bearophile


Re: Errors in TDPL

2010-06-22 Thread Jonathan M Davis
Andrei Alexandrescu wrote:

 
 Walter, was that intentional? The grammar has no semicolon but the
 example does. That makes the example wrong because you agreed there is
 no solitary semicolon statement in D, and TDPL does mention that.
 
 IMHO the semicolon makes for more robust code. Consider:
 
 do
 {
  ... lotsa code ...
 }
 while (fun(i))
 ++i;
 
 A maintainer might see the while and conclude that ++i; was meant to be
 the loop, indent it, and call it a day. The absence of the semicolon
 thus created a contextual dependency on the presence of the do keyword
 upstream.
 
 Walter, can we require a semicolon please?
 
 
 Andrei

I have zero problem requiring a semicolon (I'd prefer it actually), but I 
believe that a lone semicolon is generally a perfectly valid statement in D 
as long as it's not where optional braces could be. Per the grammar:

Statement:
;
NonEmptyStatement
ScopeBlockStatement

I believe that all the constructs with optional braces have a 
ScopBlockStatement for their body and therefore can't have a lone semicolon. 
But a statement by itself can be a lone semicolon. Though why you'd do that, 
I don't know. The only place that I've run into that being useful has been 
with macros (which don't exist in D).

- Jonathan M Davis


Re: DMD Backend Long-term

2010-06-22 Thread Nick Sabalausky
Robert Jacques sandf...@jhu.edu wrote in message 
news:op.vepzxsdx26s...@sandford...
 On Tue, 22 Jun 2010 16:47:14 -0400, BCS n...@anon.com wrote:

 Hello Robert,

 On Mon, 21 Jun 2010 23:55:48 -0400, BCS n...@anon.com wrote:

 The main issue (as I understand it) is adding windows style structured
 exception handling to LLVM.


 After a little digging it seems that LLVM legally CAN'T add SEH as MS 
 has it under patent. I'm still digging to figure out how it could be 
 patented without making SEH an irrelevant technology.


 The patent seems to be Borlands's:
 USPTO patent #5,628,016 Patent held by Borland on compiler support for 
 SEH.
 From a Wine wiki page: http://wiki.winehq.org/CompilerExceptionSupport

 It does seem to expire on June 15, 2014, though and I assume DigitalMars 
 has a license, so a LLVM fork is not unreasonable.

Seems a weak reason. A programmer that's worried about infringing software 
patents can't write anything more useful than Hello World. I'm seriously 
not convinced at all that it's even possible to write useful code that 
doesn't technically infringe on some software patent. As a programmer, 
either you accept the fact that what you do is inevitably going to trample 
software patents, or you just simply don't be a programmer. That's all there 
is.




Re: DMD Backend Long-term

2010-06-22 Thread Brad Roberts
On Tue, 22 Jun 2010, Nick Sabalausky wrote:

 Seems a weak reason. A programmer that's worried about infringing software 
 patents can't write anything more useful than Hello World. I'm seriously 
 not convinced at all that it's even possible to write useful code that 
 doesn't technically infringe on some software patent. As a programmer, 
 either you accept the fact that what you do is inevitably going to trample 
 software patents, or you just simply don't be a programmer. That's all there 
 is.

The world's not nearly that black and white.  There's a huge difference in 
infringment in an app you write for yourself vs an app that's very public.

LLVM is somewhat closer to the latter end of the spectrum.

I agree that excess paranoia isn't warranted, but neither is willful 
ignorance.


Re: Errors in TDPL

2010-06-22 Thread Andrei Alexandrescu

On 06/22/2010 04:53 PM, bearophile wrote:

Andrei Alexandrescu:

you agreed there is no solitary semicolon statement in D,


This compiles, is this a solitary semicolon statement?

void main() {
 goto FOO;
 FOO:;
}


Yes. It shouldn't compile. Walter and I agreed that solitary semicolons 
are useless (you can always use {} as an empty statement and that 
actually makes things clearer to everyone), but it's a low-priority 
issue so he hasn't implemented that yet.


Andrei



Re: DMD Backend Long-term

2010-06-22 Thread bearophile
Robert Jacques:
 The patent seems to be Borlands's:
 USPTO patent #5,628,016 Patent held by Borland on compiler support for SEH.
  From a Wine wiki page: http://wiki.winehq.org/CompilerExceptionSupport
 
 It does seem to expire on June 15, 2014, though and I assume DigitalMars  
 has a license, so a LLVM fork is not unreasonable.

On Windows G++ supports exceptions. I have two questions:
1) Do you know how they do this? Do they have a license? If they have a licence 
why don't LLVM people too have it?
2) Why isn't LLVM just copying that part of the GCC code? If a true copy is not 
possible, why aren't copying the code with enough cosmetic changes? (A good 
amount of time ago I did believe that the main purpose of the Open Source idea 
was to copy source code between projects, to avoid reinventing things. I was so 
wrong.)

Bye,
bearophile


Re: Errors in TDPL

2010-06-22 Thread bearophile
Andrei:
  void main() {
   goto FOO;
   FOO:;
  }
 
 Yes. It shouldn't compile. Walter and I agreed that solitary semicolons 
 are useless (you can always use {} as an empty statement and that 
 actually makes things clearer to everyone),

I have had to use a LABEL:; in D code, to implement a finite state machine.
So I guess I'll have to write it like this:
LABEL: {}

Bye,
bearophile


Re: DMD Backend Long-term

2010-06-22 Thread dsimcha
== Quote from Brad Roberts (bra...@slice-2.puremagic.com)'s article
 On Tue, 22 Jun 2010, Nick Sabalausky wrote:
  Seems a weak reason. A programmer that's worried about infringing software
  patents can't write anything more useful than Hello World. I'm seriously
  not convinced at all that it's even possible to write useful code that
  doesn't technically infringe on some software patent. As a programmer,
  either you accept the fact that what you do is inevitably going to trample
  software patents, or you just simply don't be a programmer. That's all there
  is.
 The world's not nearly that black and white.  There's a huge difference in
 infringment in an app you write for yourself vs an app that's very public.
 LLVM is somewhat closer to the latter end of the spectrum.
 I agree that excess paranoia isn't warranted, but neither is willful
 ignorance.

If we're really lucky, Bilski Vs. Kappos
(http://en.wikipedia.org/wiki/In_re_Bilski) will send all the software patent
attorneys to the poorhouse next week and we can just start trampling freely.


Re: DMD Backend Long-term

2010-06-22 Thread Leandro Lucarella
bearophile, el 22 de junio a las 19:25 me escribiste:
 Robert Jacques:
  The patent seems to be Borlands's:
  USPTO patent #5,628,016 Patent held by Borland on compiler support for SEH.
   From a Wine wiki page: http://wiki.winehq.org/CompilerExceptionSupport
  
  It does seem to expire on June 15, 2014, though and I assume DigitalMars  
  has a license, so a LLVM fork is not unreasonable.
 
 On Windows G++ supports exceptions. I have two questions:
 1) Do you know how they do this? Do they have a license? If they have
 a licence why don't LLVM people too have it?
 2) Why isn't LLVM just copying that part of the GCC code? If a true
 copy is not possible, why aren't copying the code with enough cosmetic
 changes? (A good amount of time ago I did believe that the main
 purpose of the Open Source idea was to copy source code between
 projects, to avoid reinventing things. I was so wrong.)

I don't know about 1), but about 2), one of the main goals of LLVM was
to have a less restrictive license than GPL, so copying GPL code is not
an option for them.

-- 
Leandro Lucarella (AKA luca) http://llucax.com.ar/
--
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
--
HACIA NEUQUEN: EL JUEVES SALDRA CARAVANA CON PERROS
DESDE CAPITAL EN APOYO AL CACHORRO CONDENADO A MUERTE
-- Crónica TV


Re: DMD Backend Long-term

2010-06-22 Thread bearophile
Leandro Lucarella:
 but about 2), one of the main goals of LLVM was
 to have a less restrictive license than GPL, so copying GPL code is not
 an option for them.

Can't you copy it by something like 90%, enough to be able to call it different 
code (that's what I was referring with 'cosmetic changes')?

Bye,
bearophile


Re: DMD Backend Long-term

2010-06-22 Thread BCS

Hello Nick,


Robert Jacques sandf...@jhu.edu wrote in message
news:op.vepzxsdx26s...@sandford...


On Tue, 22 Jun 2010 16:47:14 -0400, BCS n...@anon.com wrote:


Hello Robert,


On Mon, 21 Jun 2010 23:55:48 -0400, BCS n...@anon.com wrote:

The main issue (as I understand it) is adding windows style
structured exception handling to LLVM.


After a little digging it seems that LLVM legally CAN'T add SEH as
MS has it under patent. I'm still digging to figure out how it could
be patented without making SEH an irrelevant technology.


The patent seems to be Borlands's:
USPTO patent #5,628,016 Patent held by Borland on compiler support
for
SEH.
From a Wine wiki page:
http://wiki.winehq.org/CompilerExceptionSupport
It does seem to expire on June 15, 2014, though and I assume
DigitalMars has a license, so a LLVM fork is not unreasonable.


Seems a weak reason. A programmer that's worried about infringing
software patents can't write anything more useful than Hello World.
I'm seriously not convinced at all that it's even possible to write
useful code that doesn't technically infringe on some software patent.
As a programmer, either you accept the fact that what you do is
inevitably going to trample software patents, or you just simply don't
be a programmer. That's all there is.



Or keep an eye on what people have actually been sued over and don't do that.

In this case I'd be surprised if it could stand up in court. Unless SEH is 
insanely convoluted to implement I can't see how the patent passes the non-obviousness 
criteria.


http://en.wikipedia.org/wiki/Inventive_step_and_non-obviousness

I wonder if you can get a patent thrown out as invalid without someone infringing 
on it?


--
... IXOYE





  1   2   >