Search found 51 matches

by frank
Wed Mar 09, 2022 7:05 pm
Forum: Development
Topic: Stage 99: For-loop and the shortcut operator
Replies: 0
Views: 654

Stage 99: For-loop and the shortcut operator

The recent support for shortcut operators (stages 96-97) has a positive effect on the Sharp BASIC language overall. Not only did it improve the loop-statement (see stage 98), it also allowed for a for-statement with an acceptable syntax, something we've been struggling with for months. A C-like for-...
by frank
Tue Mar 08, 2022 9:59 am
Forum: Development
Topic: Stage 98: Loop statement does it
Replies: 0
Views: 552

Stage 98: Loop statement does it

The new shortcut operators (see stages 96-97) allow for a more flexible and readable loop statement, so flexible in fact that Sharp BASIC's count statement (aka the for-loop) has almost become superfluous and certainly "ugly" (keep in mind this is still pre-alpha stage). Consider the follo...
by frank
Mon Mar 07, 2022 7:49 pm
Forum: Development
Topic: Stage 97: Shortcut Operators :+, :-, :*, :/
Replies: 0
Views: 484

Stage 97: Shortcut Operators :+, :-, :*, :/

Next to the increment (:++) and decrement (:--) operators (see stage 96), Sharp BASIC supports the 'shortcut' assignment operators :+ (addition), :- (subtraction), :* (multiplication) and :/ (division). Example: dim a:int=5; main do a:+5; ' equivalent to "a = a + 5;" print(a); ' 10 a:-3; '...
by frank
Sat Mar 05, 2022 10:10 am
Forum: Development
Topic: Stage 96: Shortcut Operators :++ / :--
Replies: 0
Views: 522

Stage 96: Shortcut Operators :++ / :--

At this stage the operators :++ (increment) and :-- (decrement) were added. These operators always start with a colon to avoid ambiguity. Example of an increment statement: my_value:++; will increment my_value by 1. Some pointer specific built-in procedures accept a trailing increment / decrement op...
by frank
Tue Mar 01, 2022 6:42 pm
Forum: Development
Topic: Stage 94-95: Structures
Replies: 0
Views: 693

Stage 94-95: Structures

Currently, structures (aka user-defined types) are being implemented. Structures in Sharp BASIC work the same as in most other languages. The following example has been compiled and run successfully. The next step is to implement nested structures. ' SharpBASIC structure 1 ' ---------------------- i...
by frank
Sun Feb 20, 2022 2:39 pm
Forum: Development
Topic: Stage 93: Let's jump!
Replies: 0
Views: 575

Stage 93: Let's jump!

Sharp BASIC supports jump statements, which would be equivalent to BASIC's goto . However, in Sharp BASIC the keyword for this statement is jump . The statement allows for an immediate jump to a label, but only inside subroutines or functions. Labels start with the symbol @ immediately followed by ...
by frank
Sat Feb 19, 2022 4:22 pm
Forum: Development
Topic: Stage 92: let's concatenate!
Replies: 0
Views: 572

Stage 92: let's concatenate!

This stage is a major milestone in the development of the Sharp BASIC compiler. After implementing string assignment and passing managed by a reference count system, the final step of string support is concatenation. With assignment and passing in place, this was relatively easy. Example of concaten...
by frank
Wed Feb 16, 2022 8:51 pm
Forum: Development
Topic: Stages 89-91
Replies: 1
Views: 630

Re: Stages 89-91

Example of a variable-length string passed as const. Contrary to passing a constant string as const (which references the constant string), passing a variable or fixed length string as const actually passes a copy of the string: decl func test1(const v:str):str; const c = "hello world"; di...
by frank
Tue Feb 15, 2022 9:01 pm
Forum: Development
Topic: Stages 89-91
Replies: 1
Views: 630

Stages 89-91

These stages were problematic. Due to a change in string reference counting, several string routines in the system library had to be partially rewritten. At the same time, support for the cref (constant reference) parameter qualifier was dropped because of too much complexity at the current stage. R...