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.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.
Wiki improvements
-
- Posts: 564
- Joined: Sep 27, 2016 18:20
- Location: Valencia, Spain
Re: Wiki improvements
Re: Wiki improvements
'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.
'FUNCTION = variable' => default constructor call, then let operator call.
'RETURN variable' => copy-constructor call only.
-
- Posts: 564
- Joined: Sep 27, 2016 18:20
- Location: Valencia, Spain
Re: Wiki improvements
> 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.
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.
Re: Wiki improvements
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 ...
aka: single source code, for both compilers 32/64 bit's ...
Re: Wiki improvements
Extract from the Constructor documentation page: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 Operator Let (Assign) 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.
.....
.....
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).
.....
-
- Posts: 564
- Joined: Sep 27, 2016 18:20
- Location: Valencia, Spain
Re: Wiki improvements
Thanks very much. I was reading the "Return" and "Returning a Value" topics instead.
Re: Wiki improvements
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) ?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 ...
But you are free to propose more exhaustive and more detailed post(s) :-)
Re: Wiki improvements
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.
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.
Re: Wiki improvements
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.
Everyone is free to propose something, but something concrete.
Re: Wiki improvements
I have replaced the example code. Please me me know or edit the example if you see a bug or possible improvements.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.
Re: Wiki improvements
At once complete and easily understandable.
Thank you.
Thank you.
-
- Posts: 5
- Joined: Jul 19, 2017 19:04
Re: Wiki improvements
All good, thank you very much.badidea wrote:I have replaced the example code. Please me me know or edit the example if you see a bug or possible improvements.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.
Re: Wiki improvements
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)
Is it a personal behavior (because of my new rights) or general?
(It was not like this the first days of my new rights)
Re: Wiki improvements
In my posts its not a new behavior. The "last edited" appeared a hour ago.
Re: Wiki improvements
Yes, seems like it. I also get the 'Last edited...' here as normal...fxm wrote:Is it a personal behavior (because of my new rights) or general?