Ramblings in Ada

Everything related to programming.
Post Reply
draconic74
Green Beret
Posts: 3470
Joined: Sat Jun 03, 2006 11:08 am
Contact:

Ramblings in Ada

Post by draconic74 » Sun Nov 13, 2011 3:37 am

It's 3:20 AM and I finally got what to do for this damn Ada assignment. I would be finished already if this were C++, but because arrays don't work the same way, and neither does looping or comparing, it's taken much longer. Also, I miss that you can't add floats to integers to booleans. THEY ARE ALL NUMBERS, I'LL DEAL WITH THE ROUNDING ERRORS MYSELF TYVM.

Anyways, I said before how Ada sort of mocks you when you get errors. A snippet of terminal output for your amusement. User and computer name may have been changed. Or not. It's up to you to figure out how engrained the Draconic74 persona is into my very being.

Code: Select all

Teh-Drac-Mac:Assignment 2 draconissoventefor$ gnatmake roman_io.adb
gcc -c roman_io.adb
roman_io.adb:38:17: "end if;" expected for "if" at line 30
roman_io.adb:40:17: declarations must come before "begin"
roman_io.adb:87:01: missing "end;" for "begin" at line 75
roman_io.adb:87:01: missing "end validate_character_set;"
roman_io.adb:87:01: missing "begin" for procedure "Get" at line 21
gnatmake: "roman_io.adb" compilation error
Look at it just telling me what I did wrong... How embarrassing.

Code: Select all

Teh-Drac-Mac:Assignment 2 draconissoventefor$ gnatmake roman_io.adb
gcc -c roman_io.adb
roman_io.adb:38:31: missing ";"
roman_io.adb:39:17: "end validate_character_set;" expected
gnatmake: "roman_io.adb" compilation error
And even with that I still fail. Like I said: "Hey idiot, you missed a semi-colon."

Code: Select all

Teh-Drac-Mac:Assignment 2 draconissoventefor$ gnatmake roman_io.adb
gcc -c roman_io.adb
roman_io.adb:39:17: "end validate_character_set;" expected
gnatmake: "roman_io.adb" compilation error
And again: "You typed your own damn function name in wrong. How stupid are you?"

Code: Select all

Teh-Drac-Mac:Assignment 2 draconissoventefor$ gnatmake roman_io.adb
gcc -c roman_io.adb
roman_io.adb:21:24: warning: formal parameter "value" is not referenced
roman_io.adb:22:17: warning: variable "current_char" is never read and never assigned
roman_io.adb:22:31: warning: variable "next_char" is never read and never assigned
roman_io.adb:23:17: warning: variable "current_value" is never read and never assigned
roman_io.adb:23:32: warning: variable "next_value" is never read and never assigned
roman_io.adb:23:44: warning: variable "total" is never read and never assigned
roman_io.adb:24:17: warning: variable "numerals" is never read and never assigned
roman_io.adb:25:17: warning: variable "eol" is never read and never assigned
Great, now you are just showing me how little I have actually done. All that stuff needs to be actually used. All I did was define a function to process it a bit

Code: Select all

Teh-Drac-Mac:Assignment 2 draconissoventefor$
Back to work...

Anyways, I think I'll keep this here for a few purposes. I am doubtful that people want to learn Ada when you could learn something better, but if I want to post something about it at least I have space to do so. Also, if I have time I thought up an interesting project that I might try to write in C++. It has to do with Chess. And Text Files. Wut?
Image

Sparky
Delta Force
Posts: 4194
Joined: Wed Mar 31, 2004 8:59 pm
Location: New Jersey, USA
Contact:

Re: Ramblings in Ada

Post by Sparky » Sun Nov 13, 2011 2:53 pm

Time to move on to assignment 3.
Either you are groping for answers, or you are asking God and listening to Jesus.

draconic74
Green Beret
Posts: 3470
Joined: Sat Jun 03, 2006 11:08 am
Contact:

Re: Ramblings in Ada

Post by draconic74 » Mon Nov 14, 2011 5:41 am

Not at all, I'm still on Assignment 2. Which is due in 4.3333333333333333334 hours.

Maybe shouldn't have played TF2 with Fonzie for so long, but I still think it was worth it. Now, on to programming the easier part. Byez...


I am so not gonna sleep tonight (this morning?). And I am so gonna sleep all night tommorrow (today...)

EDIT: It's done. But I have not slept in almost 24 hours, and my last amount of sleep was a measly 5 hours. So now I either force myself to go to class, barely taking in anything, but at least being there. Or I just stay in my room and sleep, since none of my classes have turn-in homework. If I sleep, though, then what's to say tomorrow night, which is to say tonight, wont be different.
Alternative: Force myself to write more code, but this time for a personal project. Then sleep when completely burnt out. That will fix the sleeping problem but not the class problem. Choices choices... Imma go eat breakfast.
Image

draconic74
Green Beret
Posts: 3470
Joined: Sat Jun 03, 2006 11:08 am
Contact:

Re: Ramblings in Ada

Post by draconic74 » Thu Nov 17, 2011 4:48 pm

Effing hell. This is what I have to do to use a fixed-point number in Ada. Same thing goes with floats, just replace fixed with float. WHY THE HELL.

Code: Select all

	type freq is delta 0.001 range 0.000 .. 1.000;
	package freq_io is new fixed_io(freq);
	use freq_io;
	fre : freq;
So I define the type, then instantiate a package by sort of making a new one, with the name of the type, then I have to use the new package, then I can finally define a fixed point number. Big deal though, since I can't add it to anything but another fixed point number with the exact same range and delta value. In other words, itself. And the ONLY reason I need it is so that I can take a percentage of two other number that are, BY THE WAY, not fixed points. Friggin' awesome.

EDIT: Ok, got that figured out. Turns out I don't need the package. Or maybe I do but I don't. Who the hell knows. Onto the next problem: getting it to work with other things. I got that worked out as well. Finally found out how to use type conversions, because apparently the neither the class nor the manual to Ada really had that in an obvious place (HELLO THIS IS SOMETHING I ACTUALLY NEED).

One last problem. Ada refuses to round things. So instead of rounding errors, I just get constraint errors. Well yes, obviously I'm going to get a constraint error. If I request that a number have 2 digits after the decimal, but when I divide something I get three, it throws a massive fit. Instead of doing the sensible thing and rounding it. Now off to go figure out how to beat Ada into submission. Again.

EDIT^2: Great. Wonderful. Face-palmingly brilliant. So I spend a bunch of time looking for a solution (and I do so love spending more time looking for solutions then actually programming them) and in the end I decide to just do the stupid, but it works. So because of Ada's nice little features, I have to go and ignore them just to get the program working. Take the above code, for example. It is supposed to be a percentage expressed in 0-1 with 3 decimal points of precision. But, because of the quirks, I had to change it to this:

Code: Select all

type freq is delta 0.001 range 0.000 .. 100000.000;
See the problem? Yeah, way to go Ada. In the end I had to go and ignore the range defining feature altogether, because it's what forced the program to not work. I'll probably finish this annoying assignment and take my annoyance out on virtual avatars of soldiers so that it doesn't manifest physically in the form of my fist through my monitor. I just want to write lines, stop making me spend the entire time searching for solutions.
Image

Sparky
Delta Force
Posts: 4194
Joined: Wed Mar 31, 2004 8:59 pm
Location: New Jersey, USA
Contact:

Re: Ramblings in Ada

Post by Sparky » Thu Nov 17, 2011 7:04 pm

draconic74 wrote:But I have not slept in almost 24 hours, and my last amount of sleep was a measly 5 hours. So now I either force myself to go to class, barely taking in anything, but at least being there. Or I just stay in my room and sleep, since none of my classes have turn-in homework. If I sleep, though, then what's to say tomorrow night, which is to say tonight, wont be different.
Alternative: Force myself to write more code, but this time for a personal project. Then sleep when completely burnt out. That will fix the sleeping problem but not the class problem. Choices choices... Imma go eat breakfast.
A native dilemma for me.

I say go to sleep and "let God sort 'em out" (Duke Nuke'em quote).
Either you are groping for answers, or you are asking God and listening to Jesus.

draconic74
Green Beret
Posts: 3470
Joined: Sat Jun 03, 2006 11:08 am
Contact:

Re: Ramblings in Ada

Post by draconic74 » Thu Nov 17, 2011 7:25 pm

Too late. Now I'm on to the next, smaller assignment. Which is what the previous post was about. As soon as I can peel myself from these forums (it's like middle school all over again) I will finish the stupid thing. Then get some sleep this time. Because I have a math test in the morning. And by my calculations, I'm gonna have to do pretty damn well in it in order to pull through. I'm not bad, but I just feel these tests have WAY too little time. The only thing I hated about math homework was that it took so long for me to do it. I was good at it. What I complete I apparently get right, but I can't get through the whole thing. SO FRUSTRATING. By the end I'm madly scribbling in an attempt to get what I can on the paper.

Weekend won't be much better, because then I have a REAL math test on Tuesday. This one is just to test what we learned earlier this quarter. The next one is for what we are learning now. :?
Image

Dirk Gently
Commando
Posts: 2047
Joined: Sun Oct 21, 2007 2:34 pm
Location: 3C0E9056
Contact:

Re: Ramblings in Ada

Post by Dirk Gently » Thu Nov 17, 2011 11:20 pm

You problem, writing code in ada.

draconic74
Green Beret
Posts: 3470
Joined: Sat Jun 03, 2006 11:08 am
Contact:

Re: Ramblings in Ada

Post by draconic74 » Fri Nov 18, 2011 11:04 am

Tell that to my university. It's only for this class, luckily. I breezed through Intro to C++... Math went really, really meh. At least that test isn't worth much. I loathe not being able to check thing on a calculator when I'm doing this sort of math. I just end up spending half my time staring at problems trying to make sure that one side equals the other.

Also, I think I'm getting a divide-by-zero error due to an off-by-one error. If it is what I think it is I'll post a brief explanation to show why the convention of starting at zero exists in programming. If it isn't what I think it is, then what the hell is going on...


EDIT: Wut.
Terminal wrote:lab6_2.adb:30:25: no candidate interpretations match the actuals:
lab6_2.adb:30:25: missing argument for parameter "File" in call to "get_line" declared at a-textio.ads:253
lab6_2.adb:30:25: missing argument for parameter "Item" in call to "get_line" declared at a-textio.ads:249
lab6_2.adb:30:25: missing argument for parameter "File" in call to "get_line" declared at a-textio.ads:244

lab6_2.adb:30:25: no candidate interpretations match the actuals:
lab6_2.adb:30:25: too many arguments in call to "get_line"
lab6_2.adb:30:25: missing argument for parameter "Last" in call to "get_line" declared at a-textio.ads:249
lab6_2.adb:30:25: missing argument for parameter "Item" in call to "get_line" declared at a-textio.ads:244
So the first is with the Get() function without having a parameter. The second with just one parameter.

I don't even... Yeah. So when I said "at least Ada tells you exactly what is wrong", I take that back. Ok, I guess I'm off to figure out how to provide half a parameter to a function. Tell me if you guys know anything -_-
Image

Sparky
Delta Force
Posts: 4194
Joined: Wed Mar 31, 2004 8:59 pm
Location: New Jersey, USA
Contact:

Re: Ramblings in Ada

Post by Sparky » Sun Nov 20, 2011 1:32 pm

Let's see. Taxi, what did you have to say about this situation?
7 / 0 = ...*world explodes*
Either you are groping for answers, or you are asking God and listening to Jesus.

draconic74
Green Beret
Posts: 3470
Joined: Sat Jun 03, 2006 11:08 am
Contact:

Re: Ramblings in Ada

Post by draconic74 » Sun Dec 04, 2011 9:47 pm

Double-u tee eff Ada.

Code: Select all

		when code_nonexistant_error => put(" ITEM_CODE_NONEXISTANT_ERROR ");  return 1;
Ada says this is ok.

Code: Select all

		when code_nonexistant_error => put(" ITEM_CODE_NONEXISTANT_ERROR ");  return 0;
		when code_nonexistant_error => put(" ITEM_CODE_NONEXISTANT_ERROR ");  return -1;
These are not. ............................ wuuuuuuuut???


I can't have it be 1, it needs to be an integer outside the range of integers I am working with. None of the integers I am working with are "physically" limited to a range, it's just that I have an array, and this needs to give either a number in the array or a number outside of it. At this point I'll probably use 1000, well outside the range of the array. But what the hell... Are default integers in Ada unsigned? Gonna go test this.

EDIT: So yeah. This was not the problem code. I went through the entire program step by step using text output as makeshift breakpoints and finally isolated the problem code. Had nothing to do with integers, and the actual problem was 200 lines away. Go figure.
Image

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest