mersenneforum.org  

Go Back   mersenneforum.org > Extra Stuff > Programming

Reply
 
Thread Tools
Old 2012-02-27, 06:31   #232
Dubslow
Basketry That Evening!
 
Dubslow's Avatar
 
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88

3·29·83 Posts
Default

I would like to continue, however being a new week, I need to get back to my actual homework, including that "Photoscoop". Let's see how much C I can get done in the process.

As for the loops, one is for reading in characters, and one is so that we can cycle between reading characters and expanding the array... I guess there's got to be a way to simplify it, but 5 minutes of quick thinking isn't shedding too much light on the situation yet. I don't think I want any more hints for now -- but it'll probably be a couple of days before I'll be able to put serious work into this.
Dubslow is offline   Reply With Quote
Old 2012-02-27, 19:51   #233
jyb
 
jyb's Avatar
 
Aug 2005
Seattle, WA

2·883 Posts
Default

Quote:
Originally Posted by Dubslow View Post
Argh. This might have to take precedence, but I'll try and put some work into C over the week.
Quote:
....
Honor students: Complete the stenography class to find and display the secret picture hidden in some of the given image files.
Hilarious!
jyb is offline   Reply With Quote
Old 2012-03-02, 04:13   #234
Dubslow
Basketry That Evening!
 
Dubslow's Avatar
 
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88

3·29·83 Posts
Default

Hehe, whoever wrote ecm.c in Prime95 uses gotos for OutOfMemory exits

I have a different version of ReadLine in my head, but haven't actually written it yet :P Will probably do so within the next few days
Dubslow is offline   Reply With Quote
Old 2012-03-02, 04:44   #235
retina
Undefined
 
retina's Avatar
 
"The unspeakable one"
Jun 2006
My evil lair

2·11·283 Posts
Default

Quote:
Originally Posted by Dubslow View Post
Hehe, whoever wrote ecm.c in Prime95 uses gotos for OutOfMemory exits
Nothing wrong with gotos. A perfectly good thing to have and use. Seriously, I'm not being sarcastic. I don't buy into the nonsense about gotos being evil/bad/ruin your day/cause the world to end.

http://xkcd.com/292/

Last fiddled with by retina on 2012-03-02 at 05:08 Reason: Add a fun link
retina is online now   Reply With Quote
Old 2012-03-02, 04:44   #236
cheesehead
 
cheesehead's Avatar
 
"Richard B. Woods"
Aug 2002
Wisconsin USA

22·3·641 Posts
Default

Quote:
Originally Posted by Dubslow View Post
Hehe, whoever wrote ecm.c in Prime95 uses gotos for OutOfMemory exits
What do you recommend as an improvement?
cheesehead is offline   Reply With Quote
Old 2012-03-02, 05:16   #237
LaurV
Romulan Interpreter
 
LaurV's Avatar
 
Jun 2011
Thailand

3·3,221 Posts
Default

Quote:
Originally Posted by cheesehead View Post
What do you recommend as an improvement?
throwing exceptions :P:P
LaurV is offline   Reply With Quote
Old 2012-03-02, 05:18   #238
Dubslow
Basketry That Evening!
 
Dubslow's Avatar
 
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88

3×29×83 Posts
Default

I'm not saying it's wrong, I'm just saying... I am writing a ReadLine function that used goto's as my exit statements, in almost exactly the same way as is done in many places in ecm.c . jyb was saying I can make the function better, and without any gotos... I'm not sure how to do that, but then again I haven't put much thought into it (yet).

Last fiddled with by Dubslow on 2012-03-02 at 05:18
Dubslow is offline   Reply With Quote
Old 2012-03-02, 08:19   #239
jyb
 
jyb's Avatar
 
Aug 2005
Seattle, WA

33468 Posts
Default

Quote:
Originally Posted by Dubslow View Post
I'm not saying it's wrong, I'm just saying... I am writing a ReadLine function that used goto's as my exit statements, in almost exactly the same way as is done in many places in ecm.c . jyb was saying I can make the function better, and without any gotos... I'm not sure how to do that, but then again I haven't put much thought into it (yet).
Yes, but to be clear, I wasn't suggesting that it could be better just because it didn't need gotos. The function can be made simpler, clearer and shorter, and as an aside, upon doing that I think you will find that you don't need/want gotos.

FWIW, I think gotos are a perfectly legitimate tool, and that like most tools of any use they can be abused. They are perhaps distinguished by having the ability to screw up code far worse and in far less space than most constructs. I.e. they should be used with care.
jyb is offline   Reply With Quote
Old 2012-03-02, 10:09   #240
ldesnogu
 
ldesnogu's Avatar
 
Jan 2008
France

2×52×11 Posts
Default

Quote:
Originally Posted by LaurV View Post
throwing exceptions :P:P
Exceptions are evil: because of the support at run-time they degrade performance even when they are not used
ldesnogu is offline   Reply With Quote
Old 2012-03-02, 19:13   #241
ewmayer
2ω=0
 
ewmayer's Avatar
 
Sep 2002
República de California

101101011111112 Posts
Default

Quote:
Originally Posted by ldesnogu View Post
Exceptions are evil: because of the support at run-time they degrade performance even when they are not used
FWIW, I think gotos exception-handlers are a perfectly legitimate tool, and that like most tools of any use they can be abused.
ewmayer is offline   Reply With Quote
Old 2012-03-02, 20:52   #242
rogue
 
rogue's Avatar
 
"Mark"
Apr 2003
Between here and the

635610 Posts
Default

Quote:
Originally Posted by jyb View Post
FWIW, I think gotos are a perfectly legitimate tool, and that like most tools of any use they can be abused. They are perhaps distinguished by having the ability to screw up code far worse and in far less space than most constructs. I.e. they should be used with care.
One of the product groups in my company mandates the use of gotos because they want all functions to have a single return statement.

Then again, they didn't support C99 until two years ago. Try convincing a bunch of 40- and 50-somethings that C99 isn't evil incarnate. For them K&R C is the bible and C++ is a four letter word.

Don't get me wrong, C is a great language, but so is C++. The one you choose is dependent upon what you need to do with it. If you care about performance and memory use above all else (like many of the apps we use for factoring, sieving, primality testing), then C (or asm) is for you. If your application would benefit from encapsulation, inheritance, and polymorphism (like most business apps), then C++ is for you. Most apps would benefit from a combination of both and fortunate for us, then can be used together in the same application.
rogue is offline   Reply With Quote
Reply

Thread Tools


All times are UTC. The time now is 08:01.


Fri Aug 6 08:01:01 UTC 2021 up 14 days, 2:30, 1 user, load averages: 2.27, 2.34, 2.42

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.