Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Vanilla

Reply
 
Thread Tools Display Modes
Old September 9, 2010, 00:11   #21
Tiburon Silverflame
Swordsman
 
Join Date: Feb 2010
Posts: 405
Tiburon Silverflame is on a distinguished road
Code:
#define N_ELEMENTS(a) (sizeof(a) / sizeof((a)[0]))
This macro is needed for accurate upper loop bounds...

When I see stuff like this, boy howdy does that say, it's time to get the *_@#$ OUT of a language that is so damn primitive that this is necessary.
Tiburon Silverflame is offline   Reply With Quote
Old September 9, 2010, 06:29   #22
zaimoni
Knight
 
zaimoni's Avatar
 
Join Date: Apr 2007
Posts: 590
zaimoni is on a distinguished road
Quote:
Originally Posted by PowerDiver View Post
Why would you care about conversion when comparing?
When I care that -1<0U is counterintuitively false. Which doesn't happen in those pervasive for-loops, counting up from 0 inclusive, in V.
Quote:
Originally Posted by PowerDiver View Post
Was this historically a problem? My imagination is lacking in figuring out what the issues could be.
Context: I am showing a presumed 4th-generation programming language addict that this superannuated, knee-jerk "safety fix" for C programs is a logic paradox.
__________________
Zaiband: end the "I shouldn't have survived that" experience. V3.0.6 fork on Hg.
Zaiband 3.0.10 ETA Mar. 7 2011 (Yes, schedule slipped. Latest testing indicates not enough assert() calls to allow release.)
Z.C++: pre-alpha C/C++ compiler system (usable preprocessor). Also on Hg. Z.C++ 0.0.10 ETA December 31 2011
zaimoni is offline   Reply With Quote
Old September 9, 2010, 06:45   #23
PowerDiver
Prophet
 
Join Date: Mar 2008
Posts: 2,712
PowerDiver is on a distinguished road
Quote:
Originally Posted by zaimoni View Post
When I care that -1<0U is counterintuitively false. Which doesn't happen in those pervasive for-loops, counting up from 0 inclusive, in V.
Context: I am showing a presumed 4th-generation programming language addict that this superannuated, knee-jerk "safety fix" for C programs is a logic paradox.
Didn't there use to be some strange contexts where negative indices meant floor items in V? Maybe it is still in there.

It is quite possible to imagine using negative loop counters even when indexing into arrays. So much so that, a long time ago, I decided, for my own coding purposes, that loop counters should be signed rather than unsigned for extensibility even when it appears unsigned makes more sense. My only exception is looping over all possible packed bitflag combinations.

The only reason I'm beating this horse is that I always found the size_t stuff very strange. At least now I have an inkling why someone might want to do it. Thanks for that.
PowerDiver is offline   Reply With Quote
Old September 9, 2010, 07:06   #24
zaimoni
Knight
 
zaimoni's Avatar
 
Join Date: Apr 2007
Posts: 590
zaimoni is on a distinguished road
Quote:
Originally Posted by PowerDiver View Post
It is quite possible to imagine using negative loop counters even when indexing into arrays.
Yes. (My C memory manager reimplementation for Windows/GCC uses this to allow O(1) access to the exact size of a malloc-allocated memory block.) Note that ptrdiff_t, the result of subtracting two pointers, is a signed integer type -- and that strictly speaking operator [] is expecting one of its arguments to be a ptrdiff_t.

(Of course, std::size_t is a C++-ism; its C equivalent is size_t).
__________________
Zaiband: end the "I shouldn't have survived that" experience. V3.0.6 fork on Hg.
Zaiband 3.0.10 ETA Mar. 7 2011 (Yes, schedule slipped. Latest testing indicates not enough assert() calls to allow release.)
Z.C++: pre-alpha C/C++ compiler system (usable preprocessor). Also on Hg. Z.C++ 0.0.10 ETA December 31 2011
zaimoni is offline   Reply With Quote
Old September 9, 2010, 07:08   #25
zaimoni
Knight
 
zaimoni's Avatar
 
Join Date: Apr 2007
Posts: 590
zaimoni is on a distinguished road
Quote:
Originally Posted by PowerDiver View Post
Didn't there use to be some strange contexts where negative indices meant floor items in V? Maybe it is still in there.
It's still there. But those indices are never actually used to dereference arrays as negative values.
__________________
Zaiband: end the "I shouldn't have survived that" experience. V3.0.6 fork on Hg.
Zaiband 3.0.10 ETA Mar. 7 2011 (Yes, schedule slipped. Latest testing indicates not enough assert() calls to allow release.)
Z.C++: pre-alpha C/C++ compiler system (usable preprocessor). Also on Hg. Z.C++ 0.0.10 ETA December 31 2011
zaimoni is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bug (possible) with rating for OOD objects in r2038 Twilight Development 2 August 12, 2010 15:00
Is there such a thing as too much speed? Fendell Orcbane AAR 13 June 20, 2010 10:05
weird bug in r1877 shawnosullivan Vanilla 9 January 5, 2010 06:41
The saddest thing about ... PaulBlay Idle chatter 3 June 5, 2009 06:46
Just a weird thought! or not! NeoWizard Vanilla 2 January 25, 2009 08:54


All times are GMT +1. The time now is 06:59.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.