Oxygen Basic
Programming => Problems & Solutions => Topic started by: José Roca on October 20, 2018, 08:30:06 PM
-
I know that properties are methods in disguise, but Visual Basic and the visual designers have done so much harm that now everybody expects support for them in the classes.
-
How do you have a R/O method? Properties suggest a static value be returned even though under the covers it may be an expression. I don't think you will make much headway eliminating properties from the OOP paradigm.
-
You don't get irony, do you? Charles is British and will understand me.
Translation for Americans: O2 classes don't support properties and I'm suggesting to add this feature because, although they aren't really needed, since they are methods in disguise, people expects them.
-
Virtual objects are the only exportable form of object, common to all compilers, and virtual objects have virtual variables. Hence the need for properties.
In o2 you can 'set properties' by pseudo-assignment (like the mid statement)
c.vf()=x
class cc
========
int vp
function vf(int va) {vp=va} 'SET
function vf() as int {return vp} 'GET
end class
dim as cc c
c.vf()=42
print c.vf()
my non-ironic response :)
-
But properties have at least an index parameter.
-
Can you give us an example of property indexes, José
-
All the COM collections have an Item property with an index parameter. There was also one, whose name can't remember, that had rwo parameters.
-
There's no problem providing indexes to access members of a collection/array object
This a test piece using a direct object (new and del not required) with automatic destruction. This will work with the next o2.
ia.item(15)=42
print ia.item(15)
'2018-10-22
uses RTLobjects
class IntArray
==============
'
%= si sizeof(int)
'
int lbound 'lower limit
int ubound 'upper limit
sys buf 'data buffer
int bytes 'sizeof buffer
'
method Create(int l=0, u=0) as IntArray
=======================================
return.constructor(l,u)
end method
method constructor(int l=0, u=0)
================================
'l lbound
'u ubound
lbound=l
ubound=u
bytes=si*(ubound-lbound+1)
buf=getmemory bytes
end method
'
method destructor()
===================
freememory buf
end method
'
method item(int i,int v) 'INPUT
===============================
'SET
'i index
'v value
int a at buf+(i-lbound)*si
a=v
end method
'
method item(int i) as int 'OUTPUT
=================================
'GET
'i index
int a at buf+(i-lbound)*si
return a
end method
'
method ptr(int i) as sys 'RETURN POINTER
========================================
'GET POINTER
'i index
return buf+(i-lbound)*si
end method
'
method resize(int n) 'RESIZE ARRAY
==================================
'n number of elements
sys bo=buf
int lo=bytes
n*=si
bytes=n
buf=getmemory n
if bytes then
if n<lo then lo=n
copy buf,bo,lo
end if
freememory bo
end method
'
end class
'
'TESTS
======
let ia=Intarray.create(10,20) 'lbound, ubound
'#recordof ia
ia.item(15)=42
ia.resize(100)
print ia.item(15)
-
I personally don't care if I have to use xx.item(15) instead of xx.item = 15, but the ex-VBer's are always bugging with properties and "for each".
-
I don't think O2 needs to emulate VB, only talk to it.
-
To talk with a dead corpse? Who cares?
-
If VB stopped working on Windows, it would be a major crisis. VB isn't going away. C# is doing it's best to try and replace it.
VB was designed in a way that keeping it alive after Microsoft tried to abandon it is how it is able to stay relevant. It's not in the same boat as PowerBASIC.
-
It is an endangered specie only useful to maintain legacy applications. I never have liked it.
-
You're an API guy. Drag & Drop isn't your style. There is no bad or better, just tools to match ones skill level.
-
If it not was for the API guys, the Drag & Drop guys won't have tools.
Many years ago, a C++ programmer ironically thanked Microsoft for the creation of Visual Basic because it gave C++ programmers the opportunity to make money writing OCX's for it.
-
Microsoft's RETRY is C# and the Azure App Store.