September 06, 2004
You might consider Mango instead (at dsource.org)

There's an (independent) IO package provided that does what you want. It
supports the >>/<< syntax, but the general consensus is to use the
get()/put() syntax instead; i.e.

writer.put("Hello!").put(3.14);

reader.get(f1).get(i).get(f2);


"Ivan Senji" <ivan.senji@public.srce.hr> wrote in message
news:chh8fc$16at$1@digitaldaemon.com...
How can i:

{
    cout << "Hello!" << 3.14;
    float f1,f2;
    int i;
    cin >> f1 >> i >> f2;
}

in D?

The cout part can be done (although a lot uglier)
with printf. Some time ago i thought writef was the right
way to go. I thought if i wanted to print a string all i had to do
was writef(str), but this isn't actually the solution because if the
string i am trying to print is "%" i will get access violation.
I have to write writef("%s",str), so it is just a little smarter printf.

What about the cin part? What i am doing now is reading a line,
spliting it, checking if there are anough parts, converting each one
into the right type. Need i say that when i use cin i can enter those
two floats and an int from the example seperated by spaces or they
can be separated by enters, so my d version is really simplified
(meaning less flexibility) and it is a lot harder and longer code
to write.

Not to mention the neverending danger of using a wrong format specifier and getting things printed either the wrong way or not printed at all.

Does enyone else think that d.std needs compile time safe stdio with some heavy abuse of << and >> operators?

:)




September 06, 2004
In article <chhs9k$1drd$1@digitaldaemon.com>, Arcane Jill says...
>
>In article <chhnle$1c1n$1@digitaldaemon.com>, Stewart Gordon says...
>
>>But we could tell them that in D I write:
>>
>>     cin ~> f ~> i;
>>
>>if only that could be made true....
>
>Except that:
>
>#    cout <~ x;

My proposal chose ~< rather than <~.  I suppose it's kind of fitting considering that we have <= and >=, not <= and => or =< and >=.

But I suppose we could make them symmetrical, ~<~ and ~>~.

Stewart.


September 06, 2004
In article <chhs9k$1drd$1@digitaldaemon.com>, Arcane Jill says...
>
>In article <chhnle$1c1n$1@digitaldaemon.com>, Stewart Gordon says...
>
>>But we could tell them that in D I write:
>>
>>     cin ~> f ~> i;
>>
>>if only that could be made true....
>
>Except that:
>
>#    cout <~ x;

My proposal chose ~< rather than <~.  I suppose it's kind of fitting considering that we have <= and >=, not <= and => or =< and >=.

But I suppose we could make them symmetrical, ~<~ and ~>~.

Stewart.


September 08, 2004
"Stewart Gordon" <Stewart_member@pathlink.com> wrote in message news:chia77$1jno$1@digitaldaemon.com...
> In article <chhs9k$1drd$1@digitaldaemon.com>, Arcane Jill says...
> >
> >In article <chhnle$1c1n$1@digitaldaemon.com>, Stewart Gordon says...
> >
> >>But we could tell them that in D I write:
> >>
> >>     cin ~> f ~> i;
> >>
> >>if only that could be made true....
> >
> >Except that:
> >
> >#    cout <~ x;
>
> My proposal chose ~< rather than <~.  I suppose it's kind of fitting
considering
> that we have <= and >=, not <= and => or =< and >=.
>
> But I suppose we could make them symmetrical, ~<~ and ~>~.

The problem i see with ~< (AltGr-1 + < = 3) and ~> (AltGr-1 + Shift-< =4)
is the require more keystrokes and are harder to write than c++ stream
operaots << (<+< =2) or >> (Shift + (>>) = 3).

:)

>
> Stewart.
>
>


September 08, 2004
"antiAlias" <fu@bar.com> wrote in message news:chi0iu$1fbj$1@digitaldaemon.com...
> You might consider Mango instead (at dsource.org)

I know about Mango and it is great! But something like that should be in std library!

> There's an (independent) IO package provided that does what you want. It
> supports the >>/<< syntax, but the general consensus is to use the
> get()/put() syntax instead; i.e.

It looks like this is one general consensus i don't generally agree with :)

>
> writer.put("Hello!").put(3.14);
>
> reader.get(f1).get(i).get(f2);
>
>
> "Ivan Senji" <ivan.senji@public.srce.hr> wrote in message
> news:chh8fc$16at$1@digitaldaemon.com...
> How can i:
>
> {
>     cout << "Hello!" << 3.14;
>     float f1,f2;
>     int i;
>     cin >> f1 >> i >> f2;
> }
>
> in D?

And by the way, noone even tried to answer this question, how would you (or anyone else) write it in D using std?


September 08, 2004
In article <chmabo$e64$1@digitaldaemon.com>, Ivan Senji says...

>The problem i see with ~< (AltGr-1 + < = 3) and ~> (AltGr-1 + Shift-< =4)
>is the require more keystrokes and are harder to write than c++ stream
>operaots << (<+< =2) or >> (Shift + (>>) = 3).

I could start an off-topic thread on keyboard layouts here. UK keyboards have an extra key, not present on US keyboards. Between [L] and [ENTER] there are three keys, not two, and the extra (rightmost) one contains [#] (unshifted) and [~] (shifted). Other symbols are moved around, basically so that there's room for the British currency symbol [£] on shift-3. I've actually encountered a few US folk who went out their way to obtain British keyboards just to take advantage of that extra key.

But I don't like <~ either. The main reason I don't like it is because I /do/ like <<, and I see no reason to change it. It works for C++; programmers are already used to it; and I've heard no good arguments against it.

The only real argument I've heard against << is that it is "supposed" to mean "shift-left". But the truth is, << is not ambiguous in any way. The concept of left-shifting a stream is as nonsensical as the concept of inserting a value into an integer. Even visually, there is a difference - how often do you see in C++:

#    a << b;

meaning /anything/ other than stream insertion? If you wanted a left-shifting statement you'd instead use:

#    a <<= b;

Other (less compelling, IMO) arguments against << have been cited along the lines of "I don't like operator overloading". But that argument would rule out <~ too.

Arcane Jill


September 08, 2004
In article <chhjsh$1ao8$1@digitaldaemon.com>, Ivan Senji says...

>I have a class that implements
>static ++ static -- and static opCall.

Tell me more!

Lots of people use static opCall, of course, as a workaround for the fact that structs still don't have constructors yet. But I am intrigued about static ++ and static --

#    class A
#    {
#        SomeType static opPostInc() { return something; }
#        SomeOtherType static opPostDec() { return somethingElse; }
#    }
#
#    SomeType x = A++;           // x = something
#    SomeOtherType y = A--;      // y = somethingElse

Wow! What do you use it for?

Jill


September 08, 2004
Arcane Jill wrote:
<snip>
> The only real argument I've heard against << is that it is "supposed" to mean "shift-left". But the truth is, << is not ambiguous in any way.

Up until you get people begging for context-free semantics to match context-free grammar.

> The concept of left-shifting a stream is as nonsensical as the concept of inserting a value into an integer.
<snip>

I can imagine confusion arising in expressions like

a << (b << c);

in which the two meanings are mixed.

<snip>
> Other (less compelling, IMO) arguments against << have been cited along the lines of "I don't like operator overloading". But that argument would rule out <~ too.

They don't have to use it then - they can just call opAdd, opShl,
whatever by name.

FTM, is it really _over_loading, considering that <~ (or ~<, ~<~, whatever) have no meaning as yet?

Stewart.

-- 
My e-mail is valid but not my primary mailbox.  Please keep replies on the 'group where everyone may benefit.
September 08, 2004
"Arcane Jill" <Arcane_member@pathlink.com> wrote in message news:chmchg$fu1$1@digitaldaemon.com...
> In article <chhjsh$1ao8$1@digitaldaemon.com>, Ivan Senji says...
>
> >I have a class that implements
> >static ++ static -- and static opCall.
>
> Tell me more!

Well i use it just because i am lasy :)

I have a Tabs class that prints tabs and i didn't feel like creating instances of it. So i do

Tabs(file); //prints 0 tabs
Tabs++;
Tabs(file); /*printf  1 tabs*/
    //printf what needs to be indented
Tabs--;

> Lots of people use static opCall, of course, as a workaround for the fact
that
> structs still don't have constructors yet. But I am intrigued about static
++
> and static --
>
> #    class A
> #    {
> #        SomeType static opPostInc() { return something; }
> #        SomeOtherType static opPostDec() { return somethingElse; }
> #    }
> #
> #    SomeType x = A++;           // x = something
> #    SomeOtherType y = A--;      // y = somethingElse
>
> Wow! What do you use it for?

To support my lazyness :)

>
> Jill
>
>


September 08, 2004
Ivan Senji wrote:
<snip>
> I have a Tabs class that prints tabs and i didn't feel like
> creating instances of it. So i do

Then why make it a class at all?  Why not just a few global functions?

> Tabs(file); //prints 0 tabs
> Tabs++;
> Tabs(file); /*printf  1 tabs*/
<snip>

Huh?  Surely making the code that little bit more self-explanatory is no more effort than writing these comments?

Stewart.

-- 
My e-mail is valid but not my primary mailbox.  Please keep replies on the 'group where everyone may benefit.