November 06, 2003
Whats a mutator object ?

C

"Andy Friesen" <andy@ikagames.com> wrote in message news:bocnr5$25gn$2@digitaldaemon.com...
> Charles Sanders wrote:
>
> > But what would endl be defined as, an arbitrary number ?  How would it
know
> > i didnt actually want to output that specific number ?
> >
> > C
>
> A typedeffed value.  Or some sort of unique mutator object.
>
>   -- andy
>


November 06, 2003
Charles Sanders wrote:

>But what would endl be defined as, an arbitrary number ?  How would it know
>i didnt actually want to output that specific number ?
>
>C
>"J Anderson" <REMOVEanderson@badmama.com.au> wrote in message
>news:bocj2a$1tns$2@digitaldaemon.com...
>  
>
>>Charles Sanders wrote:
>>
>>    
>>
>>>I like it!  Im not a fan of the .nl() though it looks inconsistent, not
>>>      
>>>
>sure
>  
>
>>>how else to handle it though.
>>>
>>>C
>>>
>>>
>>>      
>>>
>>Instead of nl you could have a constant, ie endl
>>
>>stdout("hello")(" world")(47)(endl)("bar")("%06i\n", 62);
>>
>>
>>    
>>
>
>
>  
>
I'd be defined as a constant char or constant char[] or constant char*, or function (endl()).

-Anderson

November 06, 2003
Andy Friesen wrote:

> [snip]

> I think () is a bit too busy.  '~' may be better, since it's a lot less hoggish in terms of eyeball-space.  Plus, D already uses it to indicate concatenation.
>
> stdout ~ "Hello " ~ "world" ~ 47 ~ endl ~ "bar" ~ format("%06i\n", 62);
>
>  -- andy
>
Yeah, that's how I always thought it would be done.  Also with streams you've got bidirectional streams how would that be handled?

November 06, 2003
"Jonathan Andrew" <Jonathan_member@pathlink.com> wrote in message news:bocl5e$21g8$1@digitaldaemon.com...
> Also, would it make sense to
> declare Stdout
> static in stdio so you don't need to instantiate it each time?

Yes, of course. There'd be an abstract class forming the base of it, then there'd be Stdout deriving from it and sending its output to the console. stdout would be some global static. There'd also be another derivation from the base class which would enable buffered output to a file, and output to a string, etc.

I can make all that work, so the question is do people like the ()() approach, or does it just stink? Andy suggests using ~ instead, that certainly has an appeal, but I'm a bit concerned though about sinking into the C++ << quagmire <G>.


November 06, 2003

Walter wrote:
> I can make all that work, so the question is do people like the ()() approach, or does it just stink? Andy suggests using ~ instead, that certainly has an appeal, but I'm a bit concerned though about sinking into the C++ << quagmire <G>.

I dislike both, especially the ~.

If you use the ()() syntax, then it must be a general language feature,
that can be used for any function, e. g.

   MoveTo(x1,y1);
   DrawTo(x2,y1)(x2,y2)(x1,y2)(x1,y1);

If it is that way, it may be ok. It won't hurt, if it isn't used with io in the end. If it is only usable with opCall, then it is an ugly hack.

On the other hand it doesn't solve the inefficiency problem of "C++ <<",
effecitivly producing a flood of
   func(this,fmt[,type])
calls.

And it is not searchable.

And what is the advantage over:
   stream.print(...)(...)(...);
?

Even if you do this, these are still open problems
  - to pass a variable number of arguments safely
  - to get a generic interface to pass
       - any arry                                             => ArrayInfoStruct
       - any primitive (now "Type", should be "Prim[itive]")  => PrimInfoStruct
       - any object, array or primitive                       => TypeInfoStruct

It would be no good to fix the io problem without taking these into account.

-- 
Helmut Leitner    leitner@hls.via.at
Graz, Austria   www.hls-software.com
November 06, 2003
More operating overloading gunk. Hate it hate it hate it. Once again the evil zombie iostreams are sent to plague us, just wearing another head

Gilbert Grump



"Andy Friesen" <andy@ikagames.com> wrote in message news:bocnlc$25gn$1@digitaldaemon.com...
> Walter wrote:
>
> > Since with () overloading class objects can now look like functions,
I've
> > been toying with the idea of using this for formatted I/O. Here's a
trial
> > mockup of what it might look like:
> >
> > [...]
>
> > (Note that it retains the power of printf!) The issue here is how the
syntax
> > stdout("foo")("bar") looks. In C++ it would look like
stdout<<"foo"<<"bar"
> > which I don't find appealing.
>
> I think () is a bit too busy.  '~' may be better, since it's a lot less hoggish in terms of eyeball-space.  Plus, D already uses it to indicate concatenation.
>
> stdout ~ "Hello " ~ "world" ~ 47 ~ endl ~ "bar" ~ format("%06i\n", 62);
>
>   -- andy
>


November 06, 2003
"Walter" <walter@digitalmars.com> wrote in message news:bocp61$27of$1@digitaldaemon.com...
>
> "Jonathan Andrew" <Jonathan_member@pathlink.com> wrote in message news:bocl5e$21g8$1@digitaldaemon.com...
> > Also, would it make sense to
> > declare Stdout
> > static in stdio so you don't need to instantiate it each time?
>
> Yes, of course. There'd be an abstract class forming the base of it, then there'd be Stdout deriving from it and sending its output to the console. stdout would be some global static. There'd also be another derivation
from
> the base class which would enable buffered output to a file, and output to
a
> string, etc.
>
> I can make all that work, so the question is do people like the ()() approach, or does it just stink? Andy suggests using ~ instead, that certainly has an appeal, but I'm a bit concerned though about sinking into the C++ << quagmire <G>.

It's ugly, but at least it's not (mis)using operators.

I take it that the reason you want to use it is because it will do an atomic write with a result of all the individual expressions?



November 06, 2003
In article <boc9me$1g2b$1@digitaldaemon.com>, Walter says... [...]
>void main()
>{  Stdout stdout = new Stdout();
>    stdout("hello")(" world")(47).nl()("bar")("%06i\n", 62);
>}

if I understand, this would be equivalent to:

stdout.opCall("hello").opCall("
world").opCall(47).nl().opCall("bar").opCall("%06i\n", 62);

Right?

>
>(Note that it retains the power of printf!)

so this:
stdout("I am 50% stupid?");
generates a segmentation fault?

> The issue here is how the syntax
>stdout("foo")("bar") looks. In C++ it would look like stdout<<"foo"<<"bar"
>which I don't find appealing.

I like <<, I like (), I like ~ (althouhg I haven't ~ on my keyboard).

Ciao


November 06, 2003
In article <bocoep$26eh$2@digitaldaemon.com>, J Anderson says...
>
>Charles Sanders wrote:
>
>>But what would endl be defined as, an arbitrary number ?  How would it know
>>i didnt actually want to output that specific number ?
>>[...]
>
>I'd be defined as a constant char or constant char[] or constant char*, or function (endl()).

I suggest to create a special class Stdout.NLClass, define endl as a const Stdout.NLClass object, and define an opCall with a Stdout.NLClass parameter that does the job.

Ciao


November 06, 2003
I'm sorry, but I think the introduction of global variables purely for syntactic sugaring is a slippery slope that none of us will like hitting the bottom of.

In general, if you need global variables, your design is flawed.

"Roberto Mariottini" <Roberto_member@pathlink.com> wrote in message news:bocv12$2g8q$1@digitaldaemon.com...
> In article <bocoep$26eh$2@digitaldaemon.com>, J Anderson says...
> >
> >Charles Sanders wrote:
> >
> >>But what would endl be defined as, an arbitrary number ?  How would it
know
> >>i didnt actually want to output that specific number ? [...]
> >
> >I'd be defined as a constant char or constant char[] or constant char*,
> >or function (endl()).
>
> I suggest to create a special class Stdout.NLClass, define endl as a const Stdout.NLClass object, and define an opCall with a Stdout.NLClass
parameter that
> does the job.
>
> Ciao
>
>