?

Log in

No account? Create an account

Previous Entry | Next Entry

Start Counting From    W H A T ? ! ? !

weather: clear
outside: 6°C
mood: hairy spazz
*SSCCRREEEEEEEEEAAAAAAAAARRR*

I'm developing a suite of internal tools using Microsoft's Application APIs through C#. It looks like C++, smells like Java, acts like VB, but has its own soul. It lets me do my thing with the occasional "s'cuse me, Ma'am, my leg is caught in the door". But it's generally Not A Problem®.

There are arrays of item objects in a structure in another object class. No problem. They're only one-dimensional arrays. That really should be no problem (not like the five-dimensional monsters I had to deal with once).

All these arrays start at index one. *dramatic pause*       1... ... ... ONE... ... ...

Who the hell starts counting from one?!?!?!

>K}


Comments

( 20 comments — Leave a comment )
(Deleted comment)
bride
Jan. 8th, 2003 08:37 pm (UTC)
Normalians! I thought we cut off diplomatic ties with that planet inthe 60's... =}
shashin
Jan. 9th, 2003 07:23 am (UTC)
reminds me about that joke about the computer scientist that thought a child was missing. As he was doing a head count of his 5 children (lucky guy! >;p) he counted, "0... 1... 2... 3... 4... Uh, dear?"
ntang
Jan. 8th, 2003 07:58 pm (UTC)
Duh. The answer's easy: Microsoft.

So do you have to use C#, or are you just a glutton for punishment? ;)
bride
Jan. 8th, 2003 08:00 pm (UTC)
Re:
Microsoft is one of our clients =)
ntang
Jan. 8th, 2003 08:06 pm (UTC)
Re:
Ah, even worse.

Actually, one place I worked we had Microsoft as a client, and they seemed ok, although I never actually talked to anyone from Microsoft on that project.

Still, you have to wonder. Why break a rule that old and established, especially when making a language that's a derivative of several older and more established ones? It just doesn't make sense.
bride
Jan. 8th, 2003 08:28 pm (UTC)
Re:
It's an array setting that you can change. It looks like you can change it to start at whatever number you want. I just found that out. But that's even more scary. =O
ntang
Jan. 8th, 2003 08:42 pm (UTC)
Re:
Well, as long as it defaults to 0, that's actually not horrible. It leads to obfuscated code, which isn't a good thing, but it could be useful.

Then again, being mildly useful doesn't justify making code unreadable, so...
bride
Jan. 8th, 2003 09:39 pm (UTC)
It just means you'd have to keep checking the lower bound of arrays - Array.GetLowerBound( int dimension )

So, if you're traversing, instead of:

for( i = 0; i <= sizeof(Array); i++ ){
...
}


you'd have to go:

for( i = Array.GetLowerBound(1); i < Array.GetUpperBound(1); i++ ){
...
}


Which is a pain in the ass, but that's the way C# works.
pne
Jan. 8th, 2003 11:20 pm (UTC)
i < Array.GetUpperBound(1)
And I hope the compiler caches the result and doesn't make a method call on the array every time through the loop in the comparison function!

Or can arrays change size dynamically? I suppose so. In that case, you would need to recalculate each time through the loop.

(Oh, and wouldn't the "normal" example use sizeof(Array)/sizeof(Array[0]) rather than plain sizeof(Array)? After all, you want the number of elements in the array, not the number of bytes.)
bride
Jan. 8th, 2003 11:33 pm (UTC)
Re: i < Array.GetUpperBound(1)
And I hope the compiler caches the result and doesn't make a method call on the array every time through the loop in the comparison function!

Yeah, you'd stick it in a variable.

Or can arrays change size dynamically? I suppose so. In that case, you would need to recalculate each time through the loop.

Not that I know of... but it wouldn't surprise me if you could. You can do that in Perl and PHP, you just keep appending elements to the end.

(Oh, and wouldn't the "normal" example use sizeof(Array)/sizeof(Array[0]) rather than plain sizeof(Array)? After all, you want the number of elements in the array, not the number of bytes.)

Yeah, me and my pseudo-code =)
sertrel
Jan. 8th, 2003 08:04 pm (UTC)
Matlab also starts all arrays from 1. :)

I *think* Mathematica may have also, but I'm much less certain there.
bride
Jan. 8th, 2003 08:33 pm (UTC)
Oh right, I've heard that the Mathmetician breed starts counting from 1 as well.
compscilin
Jan. 8th, 2003 09:05 pm (UTC)
So this joker comes up to me asking about my handwriting, and asks me to "number these boxes". I write 1, 2, 3, 4, 5. Then he mentions this entry. Dork!

MathCAD defaults counting array positions at zero, but in we were told to change it to one. I think you can set it to any whole number though...
bride
Jan. 8th, 2003 09:09 pm (UTC)
Re:
So this joker comes up to me asking about my handwriting, and asks me to "number these boxes". I write 1, 2, 3, 4, 5. Then he mentions this entry. Dork!

Hahaha =)
sertrel
Jan. 8th, 2003 09:29 pm (UTC)
I think he's just irritated that he didn't think array-ish. Mathematics is defeating his compsci background.
compscilin
Jan. 9th, 2003 12:01 am (UTC)
I think he's just irritated that he didn't think array-ish. Mathematics is defeating his compsci background.

It has been four years since my last formal programming class. :-P You just caught me off guard.
idko
Jan. 8th, 2003 08:39 pm (UTC)
Me.
one loonie, two loonies, three...

bride
Jan. 8th, 2003 08:40 pm (UTC)
Re:
Are you a Normalian?
suicideromance
Jan. 10th, 2003 12:05 pm (UTC)
Hi. My name is Egan.
+ Found you trough a post you made in the mathematics group.
+ I'm from Texas.
+ why I'm here, what exactly is here? livejournal? or here in your journal? I'm on livejournal just because I use it as practice as I write my script for my movie, and I'm in your livejouranl because I read that you do computer programming, and I think that's amazing. As far as livejournal goes, you seem to have more substance then most.
+ I'm a 19 y/o mathematics/computer sci. major in San Antonio, TX. I'm getting my basics out of the way at the community college level. Nothing against the community colleges here, but personally, I find them boring, the people lacking in creativity and/or ambition. I listen to soul, jazz, r&b, and tons of other music genres. My spelling can be atrocious. I'm particular to film and books. I really like films from the 60's and I like a lot of the beat era poets and authors.

If you want to know anything else, just e-mail/aim me. or comment back.

Good luck with your project.
bride
Jan. 10th, 2003 12:10 pm (UTC)
Re: Hi. My name is Egan.
Hi there, nice to meet you =)

what exactly is here?

I guess I meant "here" as in "my journal".

you seem to have more substance then most.

Thanks =)

See you around =)
( 20 comments — Leave a comment )

Profile

eLouai
bride
The Bride of the First House

Latest Month

March 2015
S M T W T F S
1234567
891011121314
15161718192021
22232425262728
293031