Author Topic: Comming up features  (Read 529 times)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10758
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Comming up features
« 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

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2696
    • View Profile
Re: Comming up features
« Reply #1 on: 2020-Oct-18 »
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)

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1645
  • Particle Hawk
    • View Profile
Re: Comming up features
« Reply #2 on: 2020-Oct-21 »
is it backward compat?
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10758
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Comming up features
« Reply #3 on: 2020-Oct-22 »
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.

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5073
  • O Rly?
    • View Profile
Re: Comming up features
« Reply #4 on: 2020-Oct-22 »
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 1700 @3.9GHz, 16GB HyperX Fury 3000MHz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline c0d3r9

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 503
    • View Profile
Re: Comming up features
« Reply #5 on: 2020-Oct-22 »
I haven´t installed GLBasic a year.
Any news, any new features in the next time?
Ryzen 5 3400G - MSI B450 Tomahawk - 16GB DDR4

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10758
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Comming up features
« Reply #6 on: 2020-Oct-24 »
@Schranz0r, yes. I you can omit "self." and "[]" if the compiler clearly knows what you mean.

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5073
  • O Rly?
    • View Profile
Re: Comming up features
« Reply #7 on: 2020-Oct-26 »
Thats a nice little improvement :)
I <3 DGArray's :D

PC:
AMD Ryzen 7 1700 @3.9GHz, 16GB HyperX Fury 3000MHz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline JohnnyB

  • Mc. Print
  • *
  • Posts: 37
    • View Profile
Re: Comming up features
« Reply #8 on: 2020-Nov-12 »
Everything that makes a language less verbose is a great improvement. I hate "bloat".

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4347
    • View Profile
    • FUED
Re: Comming up features
« Reply #9 on: 2020-Nov-13 »
I actually have no idea what this is about. Even reading the examples. :(

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5073
  • O Rly?
    • View Profile
Re: Comming up features
« Reply #10 on: 2020-Nov-13 »
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 1700 @3.9GHz, 16GB HyperX Fury 3000MHz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4347
    • View Profile
    • FUED
Re: Comming up features
« Reply #11 on: 2020-Nov-14 »
ah! got it! :good:

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2696
    • View Profile
Re: Comming up features
« Reply #12 on: 2020-Nov-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)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10758
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Comming up features
« Reply #13 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?
« Last Edit: 2020-Nov-21 by Kitty Hello »

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2696
    • View Profile
Re: Comming up features
« Reply #14 on: 2020-Nov-22 »
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)