FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Why is Mango failing to use real?

 
Post new topic   Reply to topic     Forum Index -> Mango
View previous topic :: View next topic  
Author Message
Don Clugston



Joined: 05 Oct 2005
Posts: 91
Location: Germany (expat Australian)

PostPosted: Wed Jul 12, 2006 1:05 am    Post subject: Why is Mango failing to use real? Reply with quote

When looking through Mango's IO code, I've been more than a little disturbed at how often I've seen 'double' used instead of 'real'. This is most obvious in the io modules. David Gray's DGDouble module is a perfect example of how difficult (and slow) it is to output double-sized floating point numbers accurately using only doubles; the equivalent code using reals is trivial.

Mango's throwing away one of D's big advantages here.

Secondly, I'm astonished that Mango supports the "<<" syntax for stream output, following C++. That was a failed experiment in C++, and I can't understand the rationale for replicating that foolish idiom in D.

I'd like to see the high-performance of Mango IO combined with the presentation of Phobos; some of the philosophy seems to be wrong at present.
Back to top
View user's profile Send private message
kris



Joined: 27 Mar 2004
Posts: 1494
Location: South Pacific

PostPosted: Wed Jul 12, 2006 3:03 pm    Post subject: Re: Why is Mango failing to use real? Reply with quote

Hello Don ~ thanks for the feedback;

Don Clugston wrote:
When looking through Mango's IO code, I've been more than a little disturbed at how often I've seen 'double' used instead of 'real'. This is most obvious in the io modules. David Gray's DGDouble module is a perfect example of how difficult (and slow) it is to output double-sized floating point numbers accurately using only doubles; the equivalent code using reals is trivial.

Mango's throwing away one of D's big advantages here.

I'd really like to see a simpler version with better accuracy ~ would be great. I must admit that my experience with floating-point is limited, and that the floating-point converters, format() and parse(), should use real instead. Historically, they were made that way to be interchangable with DGDouble. I think you're saying that is just the wrong approach? I'd have to defer to your knowledge on the subject.

Don Clugston wrote:
Secondly, I'm astonished that Mango supports the "<<" syntax for stream output, following C++. That was a failed experiment in C++, and I can't understand the rationale for replicating that foolish idiom in D.

I'd like to see the high-performance of Mango IO combined with the presentation of Phobos; some of the philosophy seems to be wrong at present.

The "<<" syntax is actually a second-class citizen, and does not detract from the typical presentation of .put() & .get(). Whether it should be supported even at that level is a fair question. It's been asked a few times before, and people seemed to think it should remain as a benign option. Perhaps we should revisit?
Back to top
View user's profile Send private message
sean



Joined: 24 Jun 2004
Posts: 609
Location: Bay Area, CA

PostPosted: Wed Jul 12, 2006 5:55 pm    Post subject: Reply with quote

The only advantage of the C++ syntax over the whisper syntax is that it allows for reading and writing to be performed through a single interface, with get/put as the alternative. But as I beleive Mango separates Readers and Writers perhaps there isn't much of a need for this syntax? I'll admit to never having found a reason to use the C++ style of IO in Mango, so I certainly wouldn't be upset of it were deprecated.
Back to top
View user's profile Send private message
csauls



Joined: 27 Mar 2004
Posts: 278

PostPosted: Fri Jul 14, 2006 2:36 am    Post subject: Reply with quote

One can always create a custom class that is both an IReader and an IWriter, so the possibility for that special case does exist. I'd say that, in this case, one ought to do their chaining with explicit .get() and .put() calls rather than the Whisper syntax.

Or, as evil as it would be, I suppose one could alias .put() to .opCall() and .get() to .opIndex() ...? Then, when chaining, things between ()'s would be writes, and things between []'s would be reads!

reader [foo] [bar] (foo) [def] (bar) ;

Ew. Then again.......... I suppose its a little bit odd to chain read and write calls in the same statement anyway. Maybe it'd be possible to do a special .opCall() that knows what the last explicit .get/.put was? Then, one would just use the .get or .put at the beginning of the Whisper, and just ()'s thereafter, like so:

reader.get (foo) (bar) (def) ;
reader.put (def) (bar) (foo) ;

I don't suppose it'd be too hard to pull this off...

Code:

  // ... inside class ...

  private enum LastOp { None, Get, Put }
  LastOp p_lastOp = LastOp.None ;


  public void get ( ...blah... ) {
    p_lastOp = LastOp.Get ;
    // ... blah ...
  }


  public void put ( ...blah... ) {
    p_lastOp = LastOp.Put ;
    // ... blah ...
  }


  public void opCall ( ...blah... ) {
    switch (p_lastOp) {
      case LastOp.Get: get( ...blah... ); break;
      case LastOp.Put: put( ...blah... ); break;

      default:
        // ... throw an exception?
    }
  }


The only problem I can think of immediately, is in what possible way one could have the same arguments structure for both .get() and .put() so that opCall() works like both... I guess creative use of inout parameters might do it.
_________________
Chris Nicholson-Sauls
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
kris



Joined: 27 Mar 2004
Posts: 1494
Location: South Pacific

PostPosted: Fri Aug 18, 2006 10:30 am    Post subject: Reply with quote

One can also tie both Reader & Writer to the same Buffer instance. Reading occurs at the content front, whilst writing occurs at the end ~ just like a queue
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Mango All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group