Square brackets and curly brackets in expressions? - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1) +--- Forum: QBJS, BAM, and Other BASICs (https://staging.qb64phoenix.com/forumdisplay.php?fid=50) +--- Thread: Square brackets and curly brackets in expressions? (/showthread.php?tid=1472) Pages:
1
2
|
Square brackets and curly brackets in expressions? - CharlieJV - 02-13-2023 I'm thinking of adding the ability to use curly brackets and square brackets in expressions, along with parentheses, to make complex expressions easier to read. But not if square brackets (i.e. [ and ] ) and curly brackets (i.e. { and } ) are used in any way as special characters in QB64pe. Are square brackets and/or curly brackets used for any purpose in QB64pe? (I haven't noticed any.) RE: Square brackets and curly brackets in expressions? - mdijkens - 02-13-2023 Not that I know of RE: Square brackets and curly brackets in expressions? - bplus - 02-13-2023 No I don't think other brackets are used. Have you tried spacing out multiple brackets to make it clearer which nest you are in while you type a line in QB64 IDE? It can get confusing while composing. RE: Square brackets and curly brackets in expressions? - mnrvovrfc - 02-13-2023 Not in QB64PE yet but: square bracket had been used for fake array subscript into an allocated block defined by pointer, such as: Code: (Select All) int *pa, num; curly brace had been used in "initializer", ie. define the extent of an array or UDT and then put in the values for each element and/or field. Even with those grouping characters besides parenthesis, we are still needing code editors highlighting which grouping character is paired with another one... RE: Square brackets and curly brackets in expressions? - CharlieJV - 02-13-2023 (02-13-2023, 05:59 PM)bplus Wrote: No I don't think other brackets are used. Spaces? That's cute? RE: Square brackets and curly brackets in expressions? - mnrvovrfc - 02-13-2023 Code: (Select All) TODELETE=$(( (DISKSIZE - 10000)/1000 )) This is actually in one of the Bash scripts I use on Linux, which I obtained from one of the member sites of "Stackexchange-dot-com". The double-parenthesis on the outside are absolutely required to do math evaluations in an "ancient" terminal being given too many "modern" features. The script was to create a large useless file only with ASCII0 in it, to then erase it, to then create a compressed image of the entire disk that Linux was installed into. Good for distro-hoppers like me LOL. This was the original source: https://unix.stackexchange.com/a/584898 RE: Square brackets and curly brackets in expressions? - vince - 02-14-2023 some of the better IDEs and text editors will highlight opening and closing brackets to make editing expressions a little easier. There's no shame in using spaces or newlines to break up expressions although the PE ide may squish them together with autoindent enabled which is why I opt for my own formatting. I would not recommend introducing alternative brackets especially if they are interchangeable. They sometimes do that in Math but not in Basic which is a practice I personally dislike because the other brackets can sometimes indicate a different purpose in other contexts RE: Square brackets and curly brackets in expressions? - bplus - 02-14-2023 If I may remind, while you remain on the same line of QB64pe the spaces remain spaced until you move onto the next line, THEN the spaces are pushed together. And yes, the highlights are helpful in pointing the end bracket for the first on same level or vice versa. RE: Square brackets and curly brackets in expressions? - CharlieJV - 02-14-2023 (02-13-2023, 05:49 PM)CharlieJV Wrote: I'm thinking of adding the ability to use curly brackets and square brackets in expressions, along with parentheses, to make complex expressions easier to read. Just some samples I'm using to evaluate. Just enough of a subtle visual cue to see what goes with what. I think. Code: (Select All) PRINT ( [ 1 + 2 ] / [ 3 + 4 ] ) + 5 RE: Square brackets and curly brackets in expressions? - TerryRitchie - 02-14-2023 Is this something that's being considered to be implemented in QB64PE? Personally, I would find the use of multiple bracket types confusing in the BASIC dialect. Other languages, such as Python, use square brackets to identify constructs such as tuples which set them apart from evaluations. If I remember correctly I believe curly braces were used in Pascal (Delphi) for comment blocks. I don't believe I've ever run across a language that uses a mix of bracket types for evaluations. Again, my personal opinion, but I believe this would cause confusion. |