C vs Perl

?

=?iso-8859-1?Q?Juli=E1n?= Albo

len v escribió:
(...)

I see your point and that is exactly what Perl is all about. If your
FoxTrot implementation had something to offer the community then FoxTrot
would be added to Perl.

Something like...?

#!/usr/bin/perl

use Bizarre::FoxTrot;

Do it;

Regards.
 
J

Jerry Coffin

[email protected] says... said:
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
using namespace std;

int main ()
{
fill_n (ostream_iterator <string> (cout, "\n"),
500, string ("I will not throw paper airplanes in
class") );
}

std::string supports implicit conversions from C strings, so this can be
reduced a bit further:

#include <ostream>
#include <string>
#include <algorithm>
#include <iterator>
using namespace std;

int main ()
{
fill_n (ostream_iterator <string> (cout, "\n"),
500, "I will not throw paper airplanes in class");
}

Also note that I've included <ostream> instead of <iostream> --
including <iostream> _usually_ declares std::cout, but isn't required
to.
 
S

Stephen M. Webb

Julián Albo said:
red floyd escribi :




Mine is better ;)

#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
using namespace std;

int main ()
{
fill n (ostream iterator <string> (cout, "\n"),
500, string ("I will not throw paper airplanes in
class") );
}

Feh.

#include <iostream>

struct C {
C() { std::cout << "I will not throw paper airplanes in class\n"; }
} c[500];

int main() { return 0; }

Why resort to complexity? Brevity is the soul of wit.
 
P

Programmer Dude

len said:
Looks like I spelled it wrong on the web site too.

That was why I mentioned it. (-:
I've always maintained that a programmer does not have to spell
correctly, just consistent, either right or wrong - the syntax
checker does not care.

I would disagree. For many reasons.

Comments, tech docs, communicating effectively with others.....
 
?

=?iso-8859-1?Q?Juli=E1n?= Albo

Jerry Coffin escribió:
std::string supports implicit conversions from C strings, so this can be
reduced a bit further:

True. I was under the impression that implicit conversion will not allow
correct template argument deduction, but not.
Also note that I've included <ostream> instead of <iostream> --
including <iostream> _usually_ declares std::cout, but isn't required
to.

True again. My bad habit.

Regards.
 
?

=?iso-8859-1?Q?Juli=E1n?= Albo

"Stephen M. Webb" escribió:
#include <iostream>

struct C {
C() { std::cout << "I will not throw paper airplanes in class\n"; }
} c[500];

int main() { return 0; }

Why resort to complexity? Brevity is the soul of wit.

Nice solution, but vastes memory if great values of 500 were used ;)

Regards.
 
M

Mike Wahler

Stephen M. Webb said:
Julián Albo <[email protected]> wrote in message
red floyd escribi :


c
lass."));

Mine is better ;)

#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
using namespace std;

int main ()
{
fill n (ostream iterator <string> (cout, "\n"),
500, string ("I will not throw paper airplanes in
class") );
}

Feh.

#include <iostream>

struct C {
C() { std::cout << "I will not throw paper airplanes in class\n"; }
} c[500];

int main() { return 0; }

Why resort to complexity? Brevity is the soul of wit.

Well then, throw out that 'return' statement too.


-Mike
 
W

W K

Programmer Dude said:
That was why I mentioned it. (-:


I would disagree. For many reasons.

Comments, tech docs, communicating effectively with others.....

They're all dyslexic too, so it doesn't matter.
 
K

Kevin Goodsell

Jerry said:
Also note that I've included <ostream> instead of <iostream> --
including <iostream> _usually_ declares std::cout, but isn't required
to.

The C++ standard appears to require std::cout be declared in <iostream>:

27.3 Standard iostream objects [lib.iostream.objects]

Header <iostream> synopsis

namespace std {
extern istream cin;
extern ostream cout;
extern ostream cerr;
extern ostream clog;

extern wistream wcin;
extern wostream wcout;
extern wostream wcerr;
extern wostream wclog;
}

As far as I know, the thing that people usually assume is in iostream
which is technically not required to be is std::endl - though I believe
this is considered a defect.

-Kevin
 
M

Micah Cowan

Jerry Coffin said:
Also note that I've included <ostream> instead of <iostream> --
including <iostream> _usually_ declares std::cout, but isn't required
to.

This is a bizarre statement. Perhaps you meant the other way
around, but that doesn't make much sense either. Read your
standard, and try again.

#include <iostream>

Is *guaranteed* to declare as follows:

namespace std {
extern istream cin;
extern ostream cout;
extern ostream cerr;
extern ostream clog;
extern wistream wcin;
extern wostream wcout;
extern wostream wcerr;
extern wostream wclog;
}

It has not been my experience that ostream "usually" declares
std::cout at all; and it certainly isn't required to.

I'd have fixed the cross-post, except that I didn't want people
who are only reading alt.comp.lang.c and comp.lang.c to come away
with the wrong idea, either. Followups have been fixed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,091
Messages
2,570,604
Members
47,224
Latest member
Gwen068088

Latest Threads

Top