42

I've been working on translating a program line for line from Turbo Pascal to C, but I've apparently made some mistakes, and the version I copied from wasn't a perfect transcription of the original program. I'd like to ask about certain sections of code that I believe have a mistake within them, but on the other hand, I could swear that I read somewhere (though I can't find it now) that questions are supposed to be useful for more than just yourself.

At what point should I just struggle to work out the answer myself rather than asking it here? Am I just imagining that I read that somewhere?

16
  • 29
    If you ask about the behaviour of a particular pascal statement, it's in and output and how your C implementation doesn't work, backed by your own debug work, that is on-topic. Just a dump of code where we are aksed to fill in the hard-parts is not welcome.
    – rene
    Commented Oct 19, 2014 at 20:13
  • 4
    Although we no longer should vote to express disagreement on meta, old habits don't go away easily...
    – rene
    Commented Oct 19, 2014 at 21:25
  • You will have to course between listing your entire Pascal plus C source, and asking what a single line of Pascal translates to in C. ..I don't envy you.
    – Jongware
    Commented Oct 19, 2014 at 22:31
  • 7
    Yes, your question ought to be useful to somebody else. Easy to do, just tag it [turbo-pascal]. Don't expect a quick answer. Commented Oct 19, 2014 at 22:34
  • related (not a duplicate): When is it justifiable to downvote a question?
    – gnat
    Commented Oct 20, 2014 at 8:01
  • If your code is working but you would like to improve it then I think a better site to ask your question would be Code Review - check out their help-centre to make sure your question is within the scope for the site.
    – user2140173
    Commented Oct 20, 2014 at 9:04
  • 3
    @vba4all: Smurfton does mention that the problem is the translated code is not working.
    – Jongware
    Commented Oct 20, 2014 at 9:35
  • @Jongware sorry it wasn't too clear to me whether the code was compiling and running but had some logical error - ie. was not doing what was expected.
    – user2140173
    Commented Oct 20, 2014 at 9:43
  • 2
    it's nice when your questions help others, but i don't see why they need to. SO is here to help YOU too, as long as you ask good questions.
    – user428517
    Commented Oct 20, 2014 at 16:34
  • The issue with the code is that it compiles, but gives the wrong answer (for position of the sun in the sky). It's really just a math thing, but I don't know what some of the variables represent, and the original writer doesn't remember; he wrote it just before gps existed.
    – Smurfton
    Commented Oct 20, 2014 at 16:39
  • There is no need for manual translation. Use "p2c", the Pascal-to-C translator, Free Software Foundation. By Dave Gillespie, [email protected]. schneider.ncifcrf.gov/p2c/historic/…. I have successfully used it for translating the Pascal code for computing predictions of lunar occultations by ISBN 3-540-57701/7 (authors Oliver Montenbruck and Thomas Pfleger). Commented Oct 20, 2014 at 19:09
  • 1
    @PeterMortensen I don't know about the OP's goals, but manually translating the project is a good way to learn a new language if there's not a time constraint/the project isn't too large. That's how I learned Java, actually.
    – Kendra
    Commented Oct 20, 2014 at 21:16
  • @Kendra Hi, OP here. My goal is to translate line by line (manually) a program that my dad made for his thesis into C. Yeah, definitely is a good way of learning, but I don't think I'm going to continue with Turbo Pascal after this.
    – Smurfton
    Commented Oct 21, 2014 at 0:02
  • you never know what John Titor will find useful next...
    – CharlieS
    Commented Oct 21, 2014 at 2:35
  • 3
    @vba4all logical errors are also off-limits for Code Review ;) compiling and running is still missing a step to working. There's quite some material on that on the CR-Meta, if you're interested, feel free to read a little there.
    – Vogel612
    Commented Oct 21, 2014 at 8:23

3 Answers 3

29

There are some things in computer science( every field for that matter) that only a few people use. Yes, such questions will not be helpful to a lot of people (because they are not interested in it). But it is a question nevertheless. If you think the quality of the question is good enough, then ask it. Nowhere on SO have they mentioned that you should first think about other people before asking good questions. In fact, in the future, someone else might find your question helpful. Its not how many people find this question useful but how good is the question that matters.:)

0
20

I learnt Turbo Pascal in school. Now I use C-based languages and C-based syntax a lot - PHP, Perl, C, C++, Objective C, Java... Sometimes seeing a code translation from one language into another can be extraordinarily helpful in understanding an underlying process, or how things work. Or...you know how to do it in Turbo Pascal, but can't get your head around seeing it in C....

As other respondents commented - don't just spam lines of code....ask specific questions and tag with [turbo-pascal]....you never know what you might discover

1

I believe you are mixing up "what's appropriate to post here" with the reasons for voting down. I routinely abstain from upvoting, and sometimes even downvote, answers which are unlikely to help future visitors (indeed, the tooltip on the vote down button currently reads "This answer is not useful"); but I don't nominate them for closing on those grounds (alone).

I wanted to link to authoritative sources in the help center to support this answer but I could not quickly find anything to directly support this answer. Clarifications or corrections are most welcome. (In particular, https://stackoverflow.com/help/why-vote should probably mention this detail if indeed my answer is correct.)

1
  • Not too long ago (maybe last year?) one of the options for voting to close a question was that it was "not general enough" or something like that. I'm not sure when that went away, but that might be where the OP originally got this impression.
    – DaoWen
    Commented Oct 22, 2014 at 0:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .