Wiki improvements

Forum for discussion about the documentation project.
Josep Roca
Posts: 335
Joined: Sep 27, 2016 18:20
Location: Valencia, Spain

Re: Wiki improvements

Postby Josep Roca » May 14, 2018 10:56

Note: When we use 'FUNCTION = variable', the constructor for the return value is always called the first in the executed function code, whatever the effective location of the code line 'FUNCTION = variable'. Only the copy operator's call is triggered by the location of this code line.


Works fine. Maybe when I did the first tests I had not yet implemented the copy operator because I didn't know how exactly FUNCTION = worked. Thanks for claryfying it. I'm glad that it was my mistake and not a bug.
fxm
Posts: 8175
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: Wiki improvements

Postby fxm » May 14, 2018 11:57

'RETURN variable' uses only the copy-constructor call, triggered by the location of the code line.

'FUNCTION = variable' => default constructor call, then let operator call.
'RETURN variable' => copy-constructor call only.
Josep Roca
Posts: 335
Joined: Sep 27, 2016 18:20
Location: Valencia, Spain

Re: Wiki improvements

Postby Josep Roca » May 14, 2018 12:25

> default constructor call, then let operator call.

This is what I was missing. I came from another programming language that only implements FUNCTION = and behaves differently. Is it explained in some part of the documentation that I have missed? I don't need further clarifications, but maybe another new user will do the same mistake.
MrSwiss
Posts: 2682
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Wiki improvements

Postby MrSwiss » May 14, 2018 12:52

Another thread of a general interest, could be: Differences between 32 bit and 64 bit
aka: single source code, for both compilers 32/64 bit's ...
fxm
Posts: 8175
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: Wiki improvements

Postby fxm » May 14, 2018 13:25

Josep Roca wrote:> default constructor call, then let operator call.

This is what I was missing. I came from another programming language that only implements FUNCTION = and behaves differently. Is it explained in some part of the documentation that I have missed?

Extract from the Constructor documentation page:
.....
A copy Constructor is a special constructor that initializes a new object from an existing object. There are three general cases where the copy Constructor is called: when instantiating one object and initializing it with another object (in one instruction), when passing an object by value, when an object is returned from a function by value (by using Return x statement).
Note: When an object is returned from a function by value, but by using Function = x (or function_identifier = x) assignment, the Constructor is called once at first, and then the Let (Assign) operator at each assignment.
A copy Constructor must be defined if the shallow implicit copy constructor is not sufficient. This happens in cases when the object manages dynamically allocated memory or other resources which need to be specially constructed or copied (for example if a member pointer points to dynamically allocated memory, the implicit copy constructor will simply do an implicit pointer construction and a copy of value instead of allocate memory and then perform the copy of data).
Note: Even if is defined an explicit default Constructor, it is never called by the implicit copy constructor.
.....

Extract from the Operator Let (Assign) documentation page:
.....
Let is used to overload the Operator =[>] (Assignment) operator and to distinguish it from the comparison operator Operator = (Equal).

lhs =[>] rhs will assign the rhs to lhs by invoking the Let operator procedure defined in typename.
This includes the case of an object returned from a function by value, by using Function =[>] rhs (or function_identifier =[>] rhs) assignment.
Assigning one array is not supported presently.

An operator Let (assign) must be defined if the shallow implicit copy is not sufficient. This happens in cases when the object manages dynamically allocated memory or other resources which need to be specially copied (for example if a member pointer points to dynamically allocated memory, the implicit assignment operator will simply copy the pointer value instead of allocate memory and then perform the copy of data).
.....
Josep Roca
Posts: 335
Joined: Sep 27, 2016 18:20
Location: Valencia, Spain

Re: Wiki improvements

Postby Josep Roca » May 14, 2018 13:38

Thanks very much. I was reading the "Return" and "Returning a Value" topics instead.
fxm
Posts: 8175
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: Wiki improvements

Postby fxm » May 14, 2018 15:55

MrSwiss wrote:Another thread of a general interest, could be: Differences between 32 bit and 64 bit
aka: single source code, for both compilers 32/64 bit's ...

From only coding point of view, what to say other that among all predefined numeric types, only the [U]Integer size and the pointers sizes are platform dependent (as well as structure packing and field alignment in memory) ?

But you are free to propose more exhaustive and more detailed post(s) :-)
MrSwiss
Posts: 2682
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Wiki improvements

Postby MrSwiss » May 14, 2018 17:18

Just some remarks, on your post, what has either *exhaustiveness*
or *detail* to do with relevance, based on:
- probable number of affected forum members
- importance (preventing coding mistakes, before they are made)
IMHO, there is an adjustment of priorities badly needed.
fxm
Posts: 8175
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: Wiki improvements

Postby fxm » May 14, 2018 17:50

If the subject is of importance and impacts a lot of people, it is sure that at least one person will propose some text for such an article :-)
Everyone is free to propose something, but something concrete.
badidea
Posts: 823
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Wiki improvements

Postby badidea » May 18, 2018 11:47

badidea wrote:By accident I ended up here: https://www.freebasic.net/wiki/wikka.ph ... roPgFileIO
The example code is horrible. If the introduction (4 ways to to file I/O) is still useful, I can clean up the code. Otherwise, this page can be removed I think.

I have replaced the example code. Please me me know or edit the example if you see a bug or possible improvements.
fxm
Posts: 8175
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: Wiki improvements

Postby fxm » May 18, 2018 12:22

At once complete and easily understandable.
Thank you.
WilfredoFulcher
Posts: 5
Joined: Jul 19, 2017 19:04

Re: Wiki improvements

Postby WilfredoFulcher » May 18, 2018 18:16

badidea wrote:
badidea wrote:By accident I ended up here: https://www.freebasic.net/wiki/wikka.ph ... roPgFileIO
The example code is horrible. If the introduction (4 ways to to file I/O) is still useful, I can clean up the code. Otherwise, this page can be removed I think.

I have replaced the example code. Please me me know or edit the example if you see a bug or possible improvements.


All good, thank you very much.
fxm
Posts: 8175
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: Wiki improvements

Postby fxm » May 18, 2018 22:32

Since today, I no longer see the automatic update message (like "Last edited by fxm on ..., edited N times in total") at the bottom of my post when I edit it after a reply of at least one user.
Is it a personal behavior (because of my new rights) or general?
(It was not like this the first days of my new rights)
lizard
Posts: 406
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Wiki improvements

Postby lizard » May 18, 2018 22:36

In my posts its not a new behavior. The "last edited" appeared a hour ago.
paul doe
Posts: 553
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Wiki improvements

Postby paul doe » May 18, 2018 22:49

fxm wrote:Is it a personal behavior (because of my new rights) or general?

Yes, seems like it. I also get the 'Last edited...' here as normal...

Return to “Documentation”

Who is online

Users browsing this forum: No registered users and 2 guests