Re: [MSEide-MSEgui-talk] MSElang Objects

2017-05-08 Thread Martin Schreiber
On Monday 08 May 2017 21:05:33 Sieghard wrote:
> Hallo Marcos,
>
> Du schriebst am Mon, 8 May 2017 13:12:19 -0300:
> > >> 2. In this case:
> > >>  obj2: ^objty; //on heap
> > >>
> > >> Is it possible to remove the "^"?
> > >> obj2.f1:= 123;
> > >
> > > No, obj2 is a pointer.
> > >
> > >> I think this distinction exists because "class" exists, right?
>
> How does that behave in case of _nested objects_, possibly with identically
> named fields, which might even be of different types? Is that manageable,
> or will the construct break down, at least on "pathological" casses?
>
Example?

Martin

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] MSElang Objects

2017-05-08 Thread Marcos Douglas B. Santos
On Mon, May 8, 2017 at 4:05 PM, Sieghard  wrote:
> Hallo Marcos,
>
> Du schriebst am Mon, 8 May 2017 13:12:19 -0300:
>
>> >> 2. In this case:
>> >>  obj2: ^objty; //on heap
>> >>
>> >> Is it possible to remove the "^"?
>> >> obj2.f1:= 123;
>> >>
>> > No, obj2 is a pointer.
>> >
>> >> I think this distinction exists because "class" exists, right?
>
> How does that behave in case of _nested objects_, possibly with identically
> named fields, which might even be of different types? Is that manageable,
> or will the construct break down, at least on "pathological" casses?
>
> (I'm afraid it _will_ break down.)

For me it would be the same as today, using classes.
But Martin have already disagreed about this single syntax.


Marcos Douglas

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] MSElang Objects

2017-05-08 Thread Sieghard
Hallo Marcos,

Du schriebst am Mon, 8 May 2017 13:12:19 -0300:

> >> 2. In this case:
> >>  obj2: ^objty; //on heap
> >>
> >> Is it possible to remove the "^"?
> >> obj2.f1:= 123;
> >>  
> > No, obj2 is a pointer.
> >  
> >> I think this distinction exists because "class" exists, right?  

How does that behave in case of _nested objects_, possibly with identically
named fields, which might even be of different types? Is that manageable,
or will the construct break down, at least on "pathological" casses?

(I'm afraid it _will_ break down.)

-- 
-- 
(Weitergabe von Adressdaten, Telefonnummern u.ä. ohne Zustimmung
nicht gestattet, ebenso Zusendung von Werbung oder ähnlichem)
---
Mit freundlichen Grüßen, S. Schicktanz
---



--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] MSElang Objects

2017-05-08 Thread Martin Schreiber
On Monday 08 May 2017 18:12:19 Marcos Douglas B. Santos wrote:
> On Mon, May 8, 2017 at 12:40 PM, Martin Schreiber  
wrote:
> > "
> > "ini" and "fini" work for stack and heap.
>
> In fact, this is a good idea. But why don't use [initialization] and
> [finalization]?
> The IDE has code-completion so, is better to see a code more readable,
> don't you think?
>
MSEide has no code-completion, I don't like automatism which fiddle with my 
code and I don't like popping-up windows which disturb the flow of thoughts 
while programming. ;-)

>
> You've already answered "No, obj2 is a pointer." but what about if the
> compiler change this by itself, putting a "^" because the variable
> declaration has one?
>
> var
>  obj1: objty;  //an instance on stack, needs no create() or destroy()
>  obj2: ^objty; //on heap
> begin
>  obj1.f1:= 123;
>
>  obj2:= objty.create();
>  try
>   // I did not write the '^' but the compiler will use because the
> declaration in VAR
>   obj2.f1:= 123;
>  finally
>   obj2.destroy();
>  end;
> end;
>
It contradicts the usual Pascal and MSElang pointer notation:
"
type
 recty: record
  a: int32;
  b: int32;
 end;
 precty = ^recty;

 objty: object
  a: int32;
  b: int32;
  constructor create();
 end;
 pobjty = ^objty;

var
 rec1: recty;
 rec2: precty;
 rect3: ^recty;
 obj1:= objty;
 obj2:= pobjty;
 obj3:= ^objty;
begin
 new(rec2); //new is probably not available in MSElang
 rec3:= @rec1;
 rec1.a:= 123;
 rec2^.a:= 123;
 rec3^.b:= 456;
 obj2:= objty.create();
 obj3:= @obj1;
 obj1.a:= 123;
 obj2^.a:= 123;
// obj2.a:= 123; inconsequent!
 obj3^.b:= 456;
// obj3.b:= 456; inconsequent!
"
Martin

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] MSElang Objects

2017-05-08 Thread Marcos Douglas B. Santos
On Mon, May 8, 2017 at 12:40 PM, Martin Schreiber  wrote:
> [...]
>
> No. Call it "manually":
> "
>  obj1.create();
>  obj1.destroy();
> "
> or use "ini", "fini" methods:
> "
>  objty = object
>   method theinimethod() [ini];   //called after object initialization
>   method thefinimethod() [fini]; //called before object finalization
>  end;
> "
> "ini" and "fini" work for stack and heap.

In fact, this is a good idea. But why don't use [initialization] and
[finalization]?
The IDE has code-completion so, is better to see a code more readable,
don't you think?

>> 2. In this case:
>>  obj2: ^objty; //on heap
>>
>> Is it possible to remove the "^"?
>> obj2.f1:= 123;
>>
> No, obj2 is a pointer.
>
>> I think this distinction exists because "class" exists, right?
>
> The other way around, "class" exists for convenience and where one needs the
> guarantee that the instance never is allocated on stack.

I see...

>> If is possible to remove, well, this is +1 to remove class and mantain
>> just object but without "^" in calls, but we can continue using in
>> definition.
>>
> And how to access object elements if they are allocated on stack and not
> addressed via pointer?
>
> "@obj1.f1" or "obj1↓.f1" or...?

You've already answered "No, obj2 is a pointer." but what about if the
compiler change this by itself, putting a "^" because the variable
declaration has one?

var
 obj1: objty;  //an instance on stack, needs no create() or destroy()
 obj2: ^objty; //on heap
begin
 obj1.f1:= 123;

 obj2:= objty.create();
 try
  // I did not write the '^' but the compiler will use because the
declaration in VAR
  obj2.f1:= 123;
 finally
  obj2.destroy();
 end;
end;


Marcos Douglas

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] MSElang Objects

2017-05-08 Thread Martin Schreiber
On Monday 08 May 2017 16:49:40 Marcos Douglas B. Santos wrote:
>
> Some questions:
>
> 1. In this case:
> obj1: objty;  //an instance on stack, needs no create() or destroy()
>
> if my object has create() or destroy() they will be executed automatically?
>
No. Call it "manually":
"
 obj1.create();
 obj1.destroy();
"
or use "ini", "fini" methods:
"
 objty = object
  method theinimethod() [ini];   //called after object initialization
  method thefinimethod() [fini]; //called before object finalization
 end;
"
"ini" and "fini" work for stack and heap.

> 2. In this case:
>  obj2: ^objty; //on heap
>
> Is it possible to remove the "^"?
> obj2.f1:= 123;
>
No, obj2 is a pointer.

> I think this distinction exists because "class" exists, right?

The other way around, "class" exists for convenience and where one needs the 
guarantee that the instance never is allocated on stack.

> If is possible to remove, well, this is +1 to remove class and mantain
> just object but without "^" in calls, but we can continue using in
> definition.
>
And how to access object elements if they are allocated on stack and not 
addressed via pointer?

"@obj1.f1" or "obj1↓.f1" or...?

Martin

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] MSElang Objects

2017-05-08 Thread Marcos Douglas B. Santos
On Mon, May 8, 2017 at 10:06 AM, Martin Schreiber  wrote:
> On Monday 08 May 2017 14:11:28 Marcos Douglas B. Santos wrote:
>> On Mon, May 8, 2017 at 2:39 AM, Martin Schreiber  wrote:
>> >> > One does not need to use "class", it can be removed. I thought that
>> >> > people comming from Free Pascal will like it. ;-)
>> >>
>> >> You could be right, but I think they will like more if not exist
>> >> ambiguity.
>> >>
>> >> :)
>> >
>> > Other opinions? Should "class" be removed?
>>
>> Well, if ^TObj is the same as class and you will continue using this
>> syntax then, yes, I think class should be removed.
>> But maybe we should think more about it.
>>
> In order to clarify the difference of "object" and "class":
> "object" can be allocated on stack or on heap.
> "class" is an object which always is allocated on heap -> it always must be
> instantiated by a call of a constructor by .TheConstructor() and
> it must be destroyed by a call of a destructor by
> .TheDestructor() and it has an implicit dereference for
> element access.
> "
> type
>  objty = object
>   f1: int32;
>   f2: int32;
>   constructor create();
>   destructor destroy();
>  end;
>  pobjty = ^objty;
>
>  TObj = class(objty)
>  end;
>
> constructor objty.create();
> begin
> end;
>
> destructor objty.destroy();
> begin
> end;
>
> var
>  obj1: objty;  //an instance on stack, needs no create() or destroy()
>  obj2: ^objty; //on heap
>  obj3: pobjty;
>  obj4: TObj;   //on heap
> begin
>  obj1.f1:= 123; //no create() call necessary, no destroy() call necessary
>
>  obj2:= objty.create();
>  obj2^.f1:= 123;   //note the '^' dereference
>  obj3:= objty.create();
>  obj3^.f1:= 123;   //note the '^' dereference
>  obj4:= TObj.create();
>  obj4.f1:= 123;//no '^' dereference
>  obj2.destroy();
>  obj3.destroy();
>  obj4.destroy();
> "

Ok.

Some questions:

1. In this case:
obj1: objty;  //an instance on stack, needs no create() or destroy()

if my object has create() or destroy() they will be executed automatically?

2. In this case:
 obj2: ^objty; //on heap

Is it possible to remove the "^"?
obj2.f1:= 123;

I think this distinction exists because "class" exists, right?
If is possible to remove, well, this is +1 to remove class and mantain
just object but without "^" in calls, but we can continue using in
definition.

What do you think?


Marcos Douglas

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk


Re: [MSEide-MSEgui-talk] MSElang Objects

2017-05-08 Thread Martin Schreiber
On Monday 08 May 2017 14:11:28 Marcos Douglas B. Santos wrote:
> On Mon, May 8, 2017 at 2:39 AM, Martin Schreiber  wrote:
> >> > One does not need to use "class", it can be removed. I thought that
> >> > people comming from Free Pascal will like it. ;-)
> >>
> >> You could be right, but I think they will like more if not exist
> >> ambiguity.
> >>
> >> :)
> >
> > Other opinions? Should "class" be removed?
>
> Well, if ^TObj is the same as class and you will continue using this
> syntax then, yes, I think class should be removed.
> But maybe we should think more about it.
>
In order to clarify the difference of "object" and "class":
"object" can be allocated on stack or on heap.
"class" is an object which always is allocated on heap -> it always must be 
instantiated by a call of a constructor by .TheConstructor() and 
it must be destroyed by a call of a destructor by 
.TheDestructor() and it has an implicit dereference for 
element access.
"
type
 objty = object
  f1: int32;
  f2: int32;
  constructor create();
  destructor destroy();
 end;
 pobjty = ^objty;

 TObj = class(objty)
 end;

constructor objty.create();
begin
end;

destructor objty.destroy();
begin
end;

var
 obj1: objty;  //an instance on stack, needs no create() or destroy()
 obj2: ^objty; //on heap
 obj3: pobjty;
 obj4: TObj;   //on heap
begin
 obj1.f1:= 123; //no create() call necessary, no destroy() call necessary

 obj2:= objty.create();
 obj2^.f1:= 123;   //note the '^' dereference
 obj3:= objty.create();
 obj3^.f1:= 123;   //note the '^' dereference
 obj4:= TObj.create();
 obj4.f1:= 123;//no '^' dereference
 obj2.destroy();
 obj3.destroy();
 obj4.destroy();
"

Martin

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk