"is" includes a nil test and returns false in that case.Originally Posted by JSoftware
"is" includes a nil test and returns false in that case.Originally Posted by JSoftware
I don't think so. My application crashes when I try the is operator on an uninitialized pointerOriginally Posted by VilleK
edit: or atleast it did right before.. Now I can't reproduce it anymore
Peregrinus, expectavi pedes meos in cymbalis
Nullus norvegicorum sole urinat
But if the pointer is uninitialized "is" will try to examine an instance that is void :? That's why it is crashing. When you use "is" with a pointer to nil, you get False.Originally Posted by JSoftware
Since we are all showing up our geniously designed code with awesome pointer wrestling or typecasting, let me share some of mine
this calculates proper constant for sending wav raw wave data to openal:
Code:format := AL_FORMAT_MONO8 + ((wavheader.BitsPerSample div 8) - 1) + (wavheader.NumChannels - 1) * 2;
and a similar thing for opengl texture upload:
Code:glTexImage2D(GL_TEXTURE_2D, 0, 3 + integer((format = GL_BGRA_EXT) or (format = GL_RGBA)), Width, Height, 0, format, GL_UNSIGNED_BYTE, pData);
This is my game project - Top Down City:
http://www.pascalgamedevelopment.com...y-Topic-Reboot
My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
http://www.pascalgamedevelopment.com...source+manager
My point exactlyOriginally Posted by cronodragon
Peregrinus, expectavi pedes meos in cymbalis
Nullus norvegicorum sole urinat
Why nobody had mentioned the Assigned() function? It is what is intended to check if an object/pointer is not nil in Pascal, *not* the "is" operator.
Using "is" for that purpose is a big overkill. Its purpose is to check if the object A's class is equal to or descendant of the given class.
But I do mention it in my first postOriginally Posted by Chebmaster
cool , nice to know what is fastest ... for the if x<>nil then I mostly use if Assigned(x) then (however I THINK it's slower, but no sure...)
NecroSOFT - End of line -
Assigned(x) is a pseudo-function and the compiler generates the same code for it as for x<>nilhowever I THINK it's slower, but no sure...
no, it's different that x <> nil. I had some problems if I Assigned x and freed x, x was not nil! So I used if Assigned().
NecroSOFT - End of line -
Bookmarks