Author Topic: My language  (Read 134 times)

Krice

  • Protector of the @
  • *****
  • Posts: 2083
    • View Profile
    • Email
My language
« on: February 15, 2018, 03:48:18 PM »
I've thought some ideas, like loops that have a "inside" value that could be accessed.

Code: [Select]
repeat 10
     print "the value is " repeat.value

In case of multiple loops you could use a "reference" by writing repeat 10 as x. ('as' could be generic reference keyword.) Also, the value would go from 1 to 10, not from 0 to 9.

Until would work like 'while' in C++, but same as repeat:

Code: [Select]
until 0=5
    print "the value is " until.value
    until++

In that example 0 is the initial value and when 5 it breaks out.
« Last Edit: February 15, 2018, 03:50:21 PM by Krice »

Krice

  • Protector of the @
  • *****
  • Posts: 2083
    • View Profile
    • Email
Re: My language
« Reply #1 on: February 17, 2018, 04:01:43 PM »
Function syntax looks like this:

Code: [Select]
function myfunc
integer a:0 //: is a parameter with default value 0

if a=0 return true

return 10 //gives error, first return determines the type


myfunc(1)
myfunc(a:1) //target variable, not everything has to used

The class looks pretty much same. But while I have been thinking about class I wouldn't want to do it in the way C++ does it. I think private part of the class is mostly useless, because in real life you anyway get into situation where you want to access data with get/setters, and so being private doesn't really protect the class. Also, protected keyword in C++ is just adding to confusion.