New and Delete

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
freedimension
Enthusiast
Enthusiast
Posts: 613
Joined: Tue May 06, 2003 2:50 pm
Location: Germany
Contact:

New and Delete

Post by freedimension »

For the Structures, I would appreciate a New- and a Delete-Instruction for easily allocating and freeing Memory (without the need for a variable).
The New-Command should return a pointer with which I then can do all the interesting stuff, like my very own dynamic List- and Tree-Structures.

I really really miss this and it would simplify programming in PB so much, that's for me.

Thx
Mirko
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Re: New and Delete

Post by tinman »

freedimension wrote:The New-Command should return a pointer with which I then can do all the interesting stuff, like my very own dynamic List- and Tree-Structures.
like:

*foo.mytype = AllocateMemory(Sizeof(mytype), 0)
FreeMemory(*foo)

Unfortunately, the memory library has not yet been updated to not require bank numbers. Or do you want the calling of constructor/destructor type procedures too? You could try my RawMemory library which lets you do this, but a Linux version does not exist for now (and I think the parameters are slightly different). http://www.reelmediaproductions.com/pb or my website.
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
freedimension
Enthusiast
Enthusiast
Posts: 613
Joined: Tue May 06, 2003 2:50 pm
Location: Germany
Contact:

Post by freedimension »

Yeah, but not so "complicated" (I know it's not that complicated, let's say inconvenient). I mean, other languages do have "new" and "delete", so it has to be possible to implement it without the extra size Parameter.
Post Reply