Wiki improvements

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

Re: Wiki improvements

Post by Josep Roca »

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
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Wiki improvements

Post by fxm »

'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: 564
Joined: Sep 27, 2016 18:20
Location: Valencia, Spain

Re: Wiki improvements

Post by Josep Roca »

> 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: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Wiki improvements

Post by MrSwiss »

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
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Wiki improvements

Post by fxm »

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: 564
Joined: Sep 27, 2016 18:20
Location: Valencia, Spain

Re: Wiki improvements

Post by Josep Roca »

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

Re: Wiki improvements

Post by fxm »

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 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: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Wiki improvements

Post by MrSwiss »

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
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Wiki improvements

Post by fxm »

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: 2586
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Wiki improvements

Post by badidea »

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
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Wiki improvements

Post by fxm »

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

Re: Wiki improvements

Post by WilfredoFulcher »

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
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Wiki improvements

Post by fxm »

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: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Wiki improvements

Post by lizard »

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

Re: Wiki improvements

Post by paul doe »

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...
Post Reply