=> operator

Forum for discussion about the documentation project.
speedfixer
Posts: 393
Joined: Nov 28, 2012 1:27
Location: California

=> operator

Postby speedfixer » Sep 25, 2015 23:55

I see by remarks that this is a part of FB since 0.90
I see that it is used in code examples at times, but then cannot find it in the operator list.


I see it as a note, for example, on:

http://www.freebasic.net/wiki/wikka.php ... Assignment

If this is a valid, distinctive operator, then I feel it should have listings and a page of its own, or listed under syntax and usage at the top of the page referenced above, and put into the operator list page:

http://www.freebasic.net/wiki/wikka.php ... tPgOpIndex


I already feel old. When I can't find something, I question whether it is my eyes or my brain that is failing faster.

david

edit:
I think this should apply to the member access operator shorthand '->' also and any other valid keystroke combinations, especially if they are used in code examples on the wiki. A person - especially someone new and learning, should be able to find any keyword in any example just using either the operator list or the keyword list, without going through layers of pages to find an explanation.
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Re: => operator

Postby MichaelW » Sep 26, 2015 0:36

It is documented on the DIM page as an alternate for the = assignment operator, but the wording is strange, "the => sign" and "the (=) equal sign", and there is no mention of the word "operator". It is an operator, so it should be documented as such.
fxm
Posts: 9529
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: => operator

Postby fxm » Sep 26, 2015 5:37

For a long time, "=>" can be used instead of "=" in declaration initializers, but in that case, it is more an initialization sign that the assignment operator (for example '= Any' or '=> Any' can be also used as initializer).

Recently it has been authorized in assignment expressions to solve the parser ambiguity in some cases (for example: reference assignment from a byref function with one parameter).

"=>" is not equivalent to '=" because for example it cannot be used as operator equal when comparing two expressions.
speedfixer
Posts: 393
Joined: Nov 28, 2012 1:27
Location: California

Re: => operator

Postby speedfixer » Sep 26, 2015 6:19

Exactly, fxm.

However, locating an explanation in the wiki is, at the least, difficult.

I admire your depth of understanding of all the details of FB. However, sometimes it is difficult to follow your clarifications and explanations when I can't find the symbols you use to make a point more clear. You DO make it work, though.

Most often, it is these ambiguities in the parser that force uncomfortable methods of presenting precise code to the parser.
The multiple and what should be superfluous extra parenthetical braces to distinguish UDT, members and type references look to never be explained in any place clear enough that one could just sit and study and understand. (Those extra ()()(()) drive me nuts!)

I'm old and slower than I used to be, and when you and others begin adding extra (()) around statements to fix the parsing ... it reminds me of c and c++ and the famous '= vs ==' error that took so long to catch. That is too much work to understand a BASIC program. How can someone support that solution in the future?

Anyway, an entry in the operators list would get me and others started when we see them.

Thank you
david
fxm
Posts: 9529
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: => operator

Postby fxm » Sep 26, 2015 9:05

What's the best solution for documentation:
- create a new page
- or precise that "=>' is an alias (since fbc 0.90) of "=" for the operator assignment usage.

I would advocate instead the second solution:
1) Page /wiki/KeyPgOpAssignment:
Operator =[>] (Assign)
------------------------------------------------------
Assigns a value to a variable

Syntax:
declare operator Let ( byref lhs as T1, byref rhs as T2 )

Usage:
lhs = rhs
or
lhs => rhs (from fbc version 0.90)


or, in the QB dialect,

[ Let ] lhs = rhs
or
[ Let ] lhs => rhs (from fbc version 0.90)


.....
2)Change in all links the text:
'= (Assignment)'
by:
'=[>] (Assignment)'
/wiki/CatPgOpIndex
/wiki/CatPgOpAssignment
/wiki/CatPgFunctIndex
/wiki/KeyPgLet
/wiki/KeyPgOpEqual
/wiki/KeyPgOpLet
/wiki/KeyPgOpLetlist
3) Update the text (Usage, Description) in page /wiki/KeyPgOpLet.
4) Update the text (Syntax) in page /wiki/KeyPgOpLetlist
5) Update the table (Highest Precedence) in page /wiki/OpPrecedence


[edit]
Replaced '= or =>' by '=[>]'
Last edited by fxm on Sep 29, 2015 21:26, edited 7 times in total.
Tourist Trap
Posts: 2815
Joined: Jun 02, 2015 16:24

Re: => operator

Postby Tourist Trap » Sep 26, 2015 13:18

speedfixer wrote:I see by remarks that this is a part of FB since 0.90

Nothing bad with your astonishment for me, I've made some remark about this some times ago : viewtopic.php?f=3&t=23941#p211462.

fxm wrote:What's the best solution for documentation:
- create a new page
- or precise that "=>' is an alias (since fbc 0.90) of "=" for the operator assignment usage.

Sincerely fxm, I would create anyway a page and its own link, where it is indicated that this is an alternative to = for assignement only, and give here the restrictions (not an overloadable operator) and the recommanded/usual usage (first assignation/initialization). So to summarize, the points that are interesting to learn :
  • what is this sign, an alternate sign for assignement
  • version of introduction
  • why is this not classically oriented from right to left (see dkl remark, ':' was already in use)
  • is this equivalent to = ? ---> not, so what are the restrictions compared to =
  • what is it used for ? ---> assignation/ initialization/ substitute to = in the case of possible confusion with '=='
  • any example of confusion with '==' would be welcome
  • any example of usage is in fact welcome

Then updating the = page with tiny remark and the link to the page would suffice.

My concern is that calling it an alias is still confusing a little since it is not an alias for all usages, it has restrictions.

Whatever, any addition is always a good step forward. Thanks by advance.
fxm
Posts: 9529
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: => operator

Postby fxm » Sep 26, 2015 14:19

Tourist Trap wrote:
  • why is this not classically oriented from right to left (see dkl remark, ':' was already in use)

fxm wrote:In FreeBASIC, there is also the operator <= (Less Than Or Equal).
fxm
Posts: 9529
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: => operator

Postby fxm » Sep 26, 2015 14:41

Tourist Trap wrote:I would create anyway a page and its own link, where it is indicated that this is an alternative to = for assignement only, and give here the restrictions (not an overloadable operator) and the recommanded/usual usage (first assignation/initialization).

But how it would link this new page in the different catalog-pages and in the different keyword-pages?
Two links for the same function (WEIRD)?
  • = (Assignment)
  • => (Assignment's alias)
'=> (Assignment)' as '= (Assignment)' are both overloadable through the Operator Let.
Last edited by fxm on Sep 26, 2015 19:16, edited 3 times in total.
fxm
Posts: 9529
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: => operator

Postby fxm » Sep 26, 2015 15:41

See my updated proposal post:
viewtopic.php?p=211732#p211732
speedfixer
Posts: 393
Joined: Nov 28, 2012 1:27
Location: California

Re: => operator

Postby speedfixer » Sep 27, 2015 3:18

I do like the square brackets indicating optional usage.

I would prefer NOT adding more pages than needed. No need to add to difficulty of maintenance. If there is little or no distinction in usage, not extra page is required. There are already at least 4 pages regarding assignment.

As long as someone can see the keystrokes on a list, and can find the reference and explanation, that should be satisfactory.



david
fxm
Posts: 9529
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: => operator

Postby fxm » Sep 27, 2015 7:04

Obviously I agree because this is what I have proposed:
- In summary, '=' and '=>' are now equivalent for the assignment and initialization functions (I already spotted all links of the pages to modify).
- Only '=' is allowed for the equality comparison (everywhere 'Operator = (Equal)' must not be modified).

Admin, are you in favor that I do the update in this way?
fxm
Posts: 9529
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: => operator

Postby fxm » Sep 27, 2015 20:08

fxm wrote:Admin, are you in favor that I do the update in this way?

What is the dead line for documentation update to be integrated in the next release?
Tourist Trap
Posts: 2815
Joined: Jun 02, 2015 16:24

Re: => operator

Postby Tourist Trap » Sep 29, 2015 13:11

fxm wrote:'=> (Assignment)' as '= (Assignment)' are both overloadable through the Operator Let.

I didn't know this. That's only if the operator LET was not allowed to be overload for => that I would have liked another page because this would have been a very important difference. Else, I agree for naming it an alias, or melting it in the = page mentioning that this is not equality.

You have done? will have to change many pages. About the brackets, when you use frequently the doc they fortunately loose their mystery and show to be an interesting syntax.

Out of subject or extending it, what about introducing the '==' sign as alternate for equality? So doing one could get rid of any ambiguity all the time. I'm thinking about someone who would teach freebasic for example at school for an introduction to programming and would prefere avoid this difficulty. Just a question, not a request.
fxm
Posts: 9529
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: => operator

Postby fxm » Sep 29, 2015 14:34

Yes, allow an alias for the equality operator:
'Operator =[=] (Equal)'
is interesting!
dkl
Site Admin
Posts: 3210
Joined: Jul 28, 2005 14:45
Location: Germany

Re: => operator

Postby dkl » Sep 29, 2015 16:11

If it's ready by (roughly) 2015-10-01 12:00 UTC, then it will be in the release.

It's good to have => documented next to = (assignment). I'd put it on the same page, as alternative syntax, and explain when/why it's useful. Adding information about why it's => and not <= or := is good too.

Return to “Documentation”

Who is online

Users browsing this forum: No registered users and 2 guests