Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Alternative to C Structs or C++ Classes in DB Pro

Author
Message
kc9yankee
22
Years of Service
User Offline
Joined: 5th Jan 2003
Location:
Posted: 13th Feb 2003 12:30
I can't think of anything more powerful in a language than Structs/Classes of C/C++. They allow you to define your own data types, and they provide a very helpful way to store and access data. Ever since I've started using DB Pro, I've missed those tools.

I'm curious do any of you who program or used to program in C/C++, know of a way to simulate those tools in DB Pro. DB Pro not object oriented so, I wouldn't think there is any command for a similar tool. However, I'm sure you have thought of a way to atleast structure your variables, arrays, etc, so that the organization of such, is similar to a Structure or Class.

To anyone who would care to give an answer, you have my thanks.
solo
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Israel
Posted: 13th Feb 2003 13:57
Even if you find a way to simulate the object-oriented
method, you'll be hit by the overhead.
see, youre talking about something like an emulator or interpeter that during run-time translates your simulated
OO into DB primitives.

I had my thoughts on this issue. I belive it can be done
partly.
Encapsulation of Data-Members could be achieved by formating memblocks while serializing each object with a unique ObjectID(instance) and TypeID.
Member fuctions could be created as regular functions that get extra parameters of ObjectID,TypeID(Inheritance/Polymorphism) and Pointer/Offset of memblock,
These parameters are actually replace the '*this' internal pointer of the object.
The main problem is to manage those structures in your code, allocations and deallocations,simulating pointers/references and so.
You have to TELL your program how to use your
structures, so it 'compiles' your code in run-time...
Not only a performance issue, but a headache too...

The best solution, in my opinion, is to have in the future
an access to the DB core from an outer C++ code.

Bottom line, keep your code clean and tidy.
you are dealing with a high level language.
Meanwhile, use 'memblocks' and 'TYPE'...

Dr OcCuLt
22
Years of Service
User Offline
Joined: 27th Nov 2002
Location: a Dark Deep Dark pit, it dark in here
Posted: 14th Feb 2003 01:37
i`v be thinking about this and i got an ider.why not make a program that makes a liner code out of object-oriented code.so when you press compile the text you just typet go to this program that re-makes the temp file the compiler ues in a liner from.this is a bit hard to explan and it just an ider.

--Dr 0--
solo
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Israel
Posted: 14th Feb 2003 02:29
OccuLt, if i get you right, youre thinking of a
pre-compiler parser that is able to get a text file which contains object-oriented code and converts it DB code.

I've started a year ago, coding C language for such a parser, and stopped after several months.
I belive that i used quiet the same techniques of the DB
'TYPEs' implemented by Guy Savoy, the author of DarkEdit and the current DBPro editor.

The reason i stopped is the missing support of DB for reference types (pointers). Object Oriented without pointers is useless, and the missing of support for send an Array as a parameter to a function - broke me...

If and when, DBPro will have a built in pre-compiler with
a good support for macros, and a support for pointers
(variables/functions), then i belive we can imitate OOP.

solo
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Israel
Posted: 14th Feb 2003 02:57
Guy Savoy = Guy Savoie

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 14th Feb 2003 07:11
You could use arrays to hold types/values. Your pointers are then just simple indexes into those arrays.

I'd love to see what you've come up with so far.
solo
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Israel
Posted: 14th Feb 2003 13:26
IanM, i've sent you an e-mail.
Cheers,

[solo]

Login to post a reply

Server time is: 2025-05-18 02:44:49
Your offset time is: 2025-05-18 02:44:49