Author Topic: About Properties  (Read 6052 times)

0 Members and 2 Guests are viewing this topic.

José Roca

  • Guest
About Properties
« 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.

JRS

  • Guest
Re: About Properties
« Reply #1 on: October 20, 2018, 09:24:23 PM »
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.
« Last Edit: October 20, 2018, 09:48:45 PM by John »

  • Guest
Re: About Properties
« Reply #2 on: October 20, 2018, 11:03:24 PM »
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.
« Last Edit: October 20, 2018, 11:13:26 PM by José Roca »

Charles Pegge

  • Guest
Re: About Properties
« Reply #3 on: October 21, 2018, 12:08:27 AM »
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

Code: [Select]
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 :)
« Last Edit: October 21, 2018, 01:27:59 AM by Charles Pegge »

José Roca

  • Guest
Re: About Properties
« Reply #4 on: October 21, 2018, 01:31:10 AM »
But properties have at least an index parameter.

Charles Pegge

  • Guest
Re: About Properties
« Reply #5 on: October 21, 2018, 02:15:41 AM »
Can you give us an example of property indexes, José

José Roca

  • Guest
Re: About Properties
« Reply #6 on: October 21, 2018, 06:47:59 PM »
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.

Charles Pegge

  • Guest
Re: About Properties
« Reply #7 on: October 22, 2018, 04:36:38 AM »
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)


Code: [Select]
'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)

José Roca

  • Guest
Re: About Properties
« Reply #8 on: October 22, 2018, 05:27:08 AM »
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".


JRS

  • Guest
Re: About Properties
« Reply #9 on: October 22, 2018, 09:10:32 AM »
I don't think O2 needs to emulate VB, only talk to it.

José Roca

  • Guest
Re: About Properties
« Reply #10 on: October 22, 2018, 09:54:13 AM »
To talk with a dead corpse? Who cares?

JRS

  • Guest
Re: About Properties
« Reply #11 on: October 22, 2018, 10:03:37 AM »
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.
« Last Edit: October 22, 2018, 11:01:02 AM by John »

José Roca

  • Guest
Re: About Properties
« Reply #12 on: October 22, 2018, 08:31:08 PM »
It is an endangered specie only useful to maintain legacy applications. I never have liked it.

JRS

  • Guest
Re: About Properties
« Reply #13 on: October 22, 2018, 09:01:33 PM »
You're an API guy. Drag & Drop isn't your style. There is no bad or better, just tools to match ones skill level.

José Roca

  • Guest
Re: About Properties
« Reply #14 on: October 22, 2018, 09:29:00 PM »
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.