Comming up features

Previous topic - Next topic

Kitty Hello

Next version will allow you to omit the 'self.' and the [] array indicators.
Here's a test example, that already compiles:

Code (glbasic) Select


TYPE T1
    i1%
ENDTYPE

TYPE TT
ia[] AS T1
ka[]
    FUNCTION foo:
    ALIAS p AS self.ia[0]
    ENDFUNCTION
ENDTYPE


FUNCTION foo: bar[]
LOCAL t AS TT

FOREACH a IN t.ia[]; a.i1=0; NEXT
FOREACH a IN t.ia  ; a.i1=0; NEXT

LOCAL a$[]
FOREACH b$ IN a$[]; b$="X"; NEXT
FOREACH b$ IN a$  ; b$="X"; NEXT

//  []     [] omited
t.ia[] = t.ia[]
t.ia = t.ia

foo(t.ka[])
foo(t.ka  )

ENDFUNCTION

bigsofty

Very handy and cleaner looking, thanks Gernot!  :good:
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Hemlos

is it backward compat?
Bing ChatGpt is pretty smart :O

Kitty Hello

Yes, sure. There are cases when the "self." is still required, but I try to fix that, too. It's just easier to type and most of the time redundant.

Schranz0r

Maybe i'm blind but, in function foo you use self.ia[].
So if i understand it right, i can do with the next Update this:

Code (glbasic) Select
    FUNCTION foo:
        ALIAS p AS ia[0]
    ENDFUNCTION
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Heiko

I haven´t installed GLBasic a year.
Any news, any new features in the next time?

Kitty Hello

@Schranz0r, yes. I you can omit "self." and "[]" if the compiler clearly knows what you mean.

Schranz0r

Thats a nice little improvement :)
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

JohnnyB

Everything that makes a language less verbose is a great improvement. I hate "bloat".

erico

I actually have no idea what this is about. Even reading the examples. :(

Schranz0r

In the Type-Methods you can call a Membervariable without a "self." call.
Arrays can do this: Array1[] = Array2[]  ->  shorter: Array1 = Array2 (No need to write the [])
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

erico


bigsofty

Quote from: Kitty Hello on 2020-Oct-17
Next version will allow you to omit the 'self.' and the [] array indicators.
Here's a test example, that already compiles:

Code (glbasic) Select


TYPE T1
    i1%
ENDTYPE

TYPE TT
ia[] AS T1
ka[]
    FUNCTION foo:
    ALIAS p AS self.ia[0]
    ENDFUNCTION
ENDTYPE


FUNCTION foo: bar[]
LOCAL t AS TT

FOREACH a IN t.ia[]; a.i1=0; NEXT
FOREACH a IN t.ia  ; a.i1=0; NEXT

LOCAL a$[]
FOREACH b$ IN a$[]; b$="X"; NEXT
FOREACH b$ IN a$  ; b$="X"; NEXT

//  []     [] omited
t.ia[] = t.ia[]
t.ia = t.ia

foo(t.ka[])
foo(t.ka  )

ENDFUNCTION


I've been thinking about this and I'm not sure I think its a good idea. Maybe I've got it wrong. But in longer listings this could be confusing to read, what variables are sourced from where. I think a better idea would a shorthand option for "self." say just a point ".". So "self.myVar" would become ".myVar". The precompiler would simply check for variables beginning with "."?
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Kitty Hello

#13
in C++, some call the member variables of a TYPE (class in C++) with a 'm_' prefix. The just ".2 prefix might be good, but I hesitate touching this piece of code.

I uploaded to the branch as Beta. Can someone confirm it's all working?

bigsofty

Quote from: Kitty Hello on 2020-Nov-21
in C++, some call the member variables of a TYPE (class in C++) with a 'm_' prefix. The just ".2 prefix might be good, but I hesitate touching this piece of code.

I uploaded to the branch as Beta. Can someone confirm it's all working?

I don't get back till tonight Gernot, I'll try it out when I do.
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)