You are not logged in.

Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

OlimilO

Intermediate

  • "OlimilO" is male
  • "OlimilO" started this thread

Posts: 277

Date of registration: Jan 18th 2009

Location: Germany

Occupation: software engineer

  • Send private message

1

Monday, October 26th 2009, 11:27am

VBA#VBVariant

Why does VBA#VBVariant refuse to be a reference type?
Why is it not possible to solve the ByRef-problem at least for the Variant-datatype?

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Public Sub Command1_Click()
   
   Dim v As New VBA#VBVariant(10)
   
   List1.AddItem v.intValue & " " & v.hashCode
   
   Call Foo(v)
   
   List1.AddItem v.intValue & " " & v.hashCode
   
End Sub
Public Sub Foo(ByRef v As VBA#VBVariant)
   List1.AddItem v.intValue & " " & v.hashCode
   v = New VBA#VBVariant(v.intValue + 10)
   List1.AddItem v.intValue & " " & v.hashCode
   '
   'nop you have no chance to use it as a reference type
   '
End Sub


should we create a datatype ByRefVariant?



OlimilO

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

2

Monday, October 26th 2009, 1:32pm

Wouldn't it be enough to implement a public "setVal()" method for VBA#Variant?

This should allow the usage of "Variant()" as holder object for value changes propagated back from the inner of a function.

Another option would be a user-defined class where the function can change the internal value.

Greetings

A1880

OlimilO

Intermediate

  • "OlimilO" is male
  • "OlimilO" started this thread

Posts: 277

Date of registration: Jan 18th 2009

Location: Germany

Occupation: software engineer

  • Send private message

3

Monday, October 26th 2009, 1:49pm

Quoted

Wouldn't it be enough to implement a public "setVal()" method for VBA#Variant?
Yes also my idea. Indeed setVal already exists, but private. We simply have to convert it to public.
But the compiler should be changed also, to generate another code. When we use

Jabaco Source

1
v = 10
the compiler should generate

Jabaco Source

1
v.setval(10)
instead of

Jabaco Source

1
v = new VBVariant(10)
but ... everything would be fine, if not...

whenever we write

Jabaco Source

1
Dim v as Variant
the compiler should do

Jabaco Source

1
Dim v As New Variant

the question is if the compiler should change it's behaviour?

my optinion is: Yes
OlimilO

This post has been edited 1 times, last edit by "OlimilO" (Oct 26th 2009, 2:03pm)


A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

4

Monday, October 26th 2009, 2:16pm

Hi,
a possible solution would be a Variant wrapper written in jbc rather than in Java.
The wrapper could have let/get properties to change the internal value.
This would not require any compiler changes.

Greetings

A1880

OlimilO

Intermediate

  • "OlimilO" is male
  • "OlimilO" started this thread

Posts: 277

Date of registration: Jan 18th 2009

Location: Germany

Occupation: software engineer

  • Send private message

5

Monday, October 26th 2009, 3:11pm

make VBVariant mutable

Quoted

a possible solution would be a Variant wrapper written in jbc rather than in Java.
The wrapper could have let/get properties to change the internal value.

hmm ... in Jabaco there is no operator overloading, nor is there a default-attribute for properties, is there?

please make a suggestion.

in Java every java#lang#number (= Byte, Short, Integer, Long, Single, Double) is immutable.

I think it would be great also to have the other way around and create a mutable primitive datatype. In my opinion there is no reason why VBVariant should be immutable too.



regards

OlimilO

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

6

Tuesday, October 27th 2009, 2:45pm

But the compiler should be changed also, to generate another code.


I think you (and Jabaco) need an AliasTableDialog.

Quoted

When we use

Jabaco Source

1
v = 10
the compiler should generate

Jabaco Source

1
v.setval(10)

whenever we write

Jabaco Source

1
Dim v as Variant
the compiler should do

Jabaco Source

1
Dim v As New Variant


And at http://www.jabaco.org/board/p1370-file-o…operations.html you are talking about something similar, too.


In C/C++ exists for something like that the preprocessor with the command #define.

The Jabaco-way would be a Dialog with a AliasTable, with two columns. And variable rows, where new entries can be added, other deleted or modified.
Such a AliasTable could look like this:

Source code

1
2
3
4
5
6
7
Str(%1)              | Conversion.Str(%1)
Chr(%1)              | Strings.Chr(%1)
Val(%1)              | Conversion.Val(%1)
Asc(%1)              | Strings.Asc(%1)
MsgBox(%1)           | Interaction.MsgBox(%1)
Dim %1 As Varaint    | Dim %1 As New Variant
Open %1 For %2 As %3 | OOpen %1, %2, %3


And if you would modify the table, it could be saved in a XML-file.
And with every start of Jabaco, the XML file wouldl be loaded.
So you could simply change some Syntax-things without changing the compiler itself.

Greatings
theuserbl

OlimilO

Intermediate

  • "OlimilO" is male
  • "OlimilO" started this thread

Posts: 277

Date of registration: Jan 18th 2009

Location: Germany

Occupation: software engineer

  • Send private message

7

Tuesday, October 27th 2009, 4:19pm

Backus Naur

Hi,
I am not very familiar with compiler related stuff. Are you talking about the Backus-Naur-Form?
Some wikipedia links:


Backus Naur Form
http://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form



Extended Backus Naur Form
http://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_Form



Augmented Backus Naur Form
http://en.wikipedia.org/wiki/Augmented_Backus%E2%80%93Naur_Form


OlimilO

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

8

Tuesday, October 27th 2009, 4:32pm

RE: Backus Naur

Hi,
I am not very familiar with compiler related stuff.
Then we have somethuing equal. :)

Quoted

Are you talking about the Backus-Naur-Form?
I have looked at that links. I think, you understand something wrong.

WIth

Quoted

Source code

1
2
3
Str(%1)              | Conversion.Str(%1)
Chr(%1)              | Strings.Chr(%1)
Val(%1)              | Conversion.Val(%1)
I don`t mean any code with an operator "|".
I mean a table like a JTable.
And that table would have two colums. In the left colum stands "Chr(%1)" , "Val(%1)", etc. And in the right Column there stand "Strings.Char(%1)", "Conversion.Val(%1)", etc.

The problem is, that I can not draw here a table. So I have used "code"-tag here in the forum, to show, how that table could look like.

Here in the forum is a table icon, but it don`t work:
[table]Test, test, 1, 2, 3, 4, ..[table]

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

9

Tuesday, October 27th 2009, 4:45pm

An additional note:
The AliasTableDialog can be seen as something similar like the existing ClassBrowser (which opens, when you press in Jabaco [F1]).
In the CLassBrowser you select the Classes, which will be loaded. In Java you would doing it with the import command. But the Jabaco-way is graphical. Its the GUI way.
Similar I see it with an AliasTableDialog. Thats a Dialog with an JTable, which includes Aliases. Other languges (like C/C++) doing it with the preprocessor-command #define. But Jabaco goes normally the GUI-way. And a graphical Dialog, would be the Jabaco way for something like that.

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

10

Wednesday, October 28th 2009, 10:24am

Hi,
a mutable holder object class would be something like:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
Option Explicit

Private myIVal As Integer 

Public Property Get iVal() As Integer
   iVal = myIVal
End Property

Public Property Let iVal(i As Integer)
   myIVal = i
End Property


A small test:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Public Sub Command1_Click()
   Dim h As New Holder
   
   h.iVal = 1
   
   Debug.Print h.iVal
   
   Call mySub(h)
   
   Debug.Print h.iVal

End Sub

Private Sub mySub(h As Holder)
   h.iVal = h.iVal + 1
End Sub


It could be useful to have a mechanism to define a standard property which the compiler would use for value assignments to objects.
But in terms of clarity this could be a mixed blessing. Too many "hidden features" can be rather confusing.

Greetings

A1880

OlimilO

Intermediate

  • "OlimilO" is male
  • "OlimilO" started this thread

Posts: 277

Date of registration: Jan 18th 2009

Location: Germany

Occupation: software engineer

  • Send private message

11

Wednesday, October 28th 2009, 11:42am

Hi A1880,
OK, :) compare your solution to:
ByRef in VB and in Jabaco
OlimilO

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

12

Wednesday, October 28th 2009, 2:31pm

OK, there is obviously "nichts neues auf der Erde".

All I wanted to say and demonstrate is that it is relatively easy to make VBVariant mutable and use it without compiler changes
or syntactic complications.

Greetings

A1880

OlimilO

Intermediate

  • "OlimilO" is male
  • "OlimilO" started this thread

Posts: 277

Date of registration: Jan 18th 2009

Location: Germany

Occupation: software engineer

  • Send private message

13

Wednesday, October 28th 2009, 3:17pm

OK I have already "opened" the VBVariant with a public setVal.

the following VB-Code:

Jabaco Source

1
2
3
4
5
6
7
8
9
Public Sub Command1_Click()
   Dim s As String
   s = "a string"
   Foo s
   MsgBox s
End Sub
Sub Foo(ByRef v As Variant)
   v = v & "test ByRef"
End Sub


now can easily be converted to this Jabaco-Code

Jabaco Source

1
2
3
4
5
6
7
8
9
Public Sub Command1_Click()
   Dim s 'As String
   s = "a string"
   Foo s
   MsgBox s
End Sub
Sub Foo(ByRef v As VBVariant)
   v.setVal v & "test ByRef"
End Sub


regards

OlimilO

Rate this thread
WoltLab Burning Board