• Source: It's a programming language. Now with HPPL support! 5 1
Currently:  

Author Topic: Source: It's a programming language. Now with HPPL support!  (Read 39521 times)

0 Members and 1 Guest are viewing this topic.

Offline iconmaster

  • LV3 Member (Next: 100)
  • ***
  • Posts: 82
  • Rating: +5/-0
    • View Profile
Re: Source: A WIP alternate programming language for the Prime
« Reply #60 on: November 08, 2014, 08:53:33 pm »
inline HP PPL support is definitively a good idea. Also if the calc ever supports ASM maybe Source could allow inline ASM opcodes?

My thoughts exactly.

Offline iconmaster

  • LV3 Member (Next: 100)
  • ***
  • Posts: 82
  • Rating: +5/-0
    • View Profile
Re: Source: A WIP alternate programming language for the Prime
« Reply #61 on: November 11, 2014, 06:46:35 pm »
I did a little work on parameterized types today. You use square brackets.


Code: [Select]

function test[K](a as list[K]) as K {
   return a[1]
}


@export
function main(a as list[int]) as int {
   return test(a)
}


Here, you can see two things: First, the list data type can have a type parameter; this indicates the type that can go into it or come out of it. Second, your own functions can specify type parameters, which are respected by the compiler.


EDIT: here's another example of parameters:


Code: [Select]

function do[A as int,B as int](a as A,b as B) as A {
return a+b
}


@export
function main[E as int](c as E,d as E) as E {
return do(c,d)
}
« Last Edit: November 11, 2014, 08:11:40 pm by iconmaster »

Offline iconmaster

  • LV3 Member (Next: 100)
  • ***
  • Posts: 82
  • Rating: +5/-0
    • View Profile
Re: Source: A WIP alternate programming language for the Prime
« Reply #62 on: November 12, 2014, 09:44:17 pm »
I am proud to present to you for loops! They're very powerful in Source.

All fors in Source are for-each loops. The kind of for you're used to looks like this:

Code: [Select]
@export
function test1() {
   for i in range(1,10) {
      print(i)
   }
}

A backwards for loop needs some special stuff done to it as of now; expect this to change:

Code: [Select]
@export
function test2() {
   @downloop
   for i in range(10,1,-1) {
      print(i)
   }
}

A traditional for-each loop is as so:

Code: [Select]
@export
function test3() {
   local a = [5,8,7,3]
   for v in a {
      print(v)
   }
}

Each loop, v becomes the next element of a.

You can get both the index and the element it references with the pairs() function of a list:

Code: [Select]
@export
function test4() {
   local a = [5,8,7,3]
   for i,v in a.pairs() {
      print(i~" "~v)
   }
}

Finally, you can simply have your own iterator functions. Just use the iterator keyword:

Code: [Select]
@export
function test5() {
   local a = [5,8,7,3]
   for newv in myOwnIter(a) {
      print(newv)
   }
}

iterator myOwnIter(a as list) as int {
   for v in a {
      return (v as int) + 1
   }
}

Note that the above code can also be written as:

Code: [Select]
@export
function test5() {
local a as list = [5,8,7,3]
for newv in a.myOwnIter() {
print(newv)
}
}

iterator list.myOwnIter(a as list) as int {
for v in a {
return (v as int) + 1
}
}
« Last Edit: November 12, 2014, 09:53:25 pm by iconmaster »

Offline iconmaster

  • LV3 Member (Next: 100)
  • ***
  • Posts: 82
  • Rating: +5/-0
    • View Profile
Re: Source: A WIP alternate programming language for the Prime
« Reply #63 on: November 16, 2014, 06:31:37 pm »
Right now, I'm working on developing a standard set of functions that all Source platforms get. HPPL specific ones are next.

To see how Source stuff is being divided up into packages, just go on over to https://docs.google.com/document/d/1Pe0HS0z0SAxyUH6f4UgXTKe88uxG5tcs7CyMtHha1ho/edit?usp=sharing !

I've also been working on Source bytecode optimization. It's going well.

Offline bb010g

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 428
  • Rating: +22/-1
  • I do stuff
    • View Profile
    • elsewhere on the net
Re: Source: A WIP alternate programming language for the Prime
« Reply #64 on: November 16, 2014, 09:09:57 pm »
Can you have type parameters of a rank higher than 1? That always bugged me in Java.
Arch Linux user
Haskell newbie | Warming up to Lua | Being dragged into C++
Calculators: HP 50g, HP 35s, Casio Prizm, TI-Nspire CX CAS, HP 28s, HP Prime, Mathematica 9 (if that counts)
π: 3.14...; l: 108; i: 105; e: 101; l+i+e: 314
THE CAKE IS A LIE IS A PIE

Offline iconmaster

  • LV3 Member (Next: 100)
  • ***
  • Posts: 82
  • Rating: +5/-0
    • View Profile
Re: Source: A WIP alternate programming language for the Prime
« Reply #65 on: November 18, 2014, 06:26:34 pm »
Can you have type parameters of a rank higher than 1? That always bugged me in Java.

I'm not sure. I'll have to get back to you on that one.

Anyways, My GitHub now has a wiki. There's already a getting started guide there, and soon I will be adding Source programming tutorials, specifications, and examples there. Check it out!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Source: A WIP alternate programming language for the Prime
« Reply #66 on: November 22, 2014, 10:52:33 am »
Awesome, hopefully there is enough documentation for people to use the language in the future. :)

Also I was always worried about For loops, because I know some languages seem to try very hard at making them weird. Even HP PPL is borderline with its FROM TO STEP DO syntax. Casio BASIC is the worst, I think, because it even inverts stuff. Instead of For(A,1,7,2) you have to write For 1->A To 7 Step 2 which is really weird.

Offline bb010g

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 428
  • Rating: +22/-1
  • I do stuff
    • View Profile
    • elsewhere on the net
Re: Source: A WIP alternate programming language for the Prime
« Reply #67 on: November 22, 2014, 05:53:24 pm »
Also I was always worried about For loops, because I know some languages seem to try very hard at making them weird. Even HP PPL is borderline with its FROM TO STEP DO syntax. Casio BASIC is the worst, I think, because it even inverts stuff. Instead of For(A,1,7,2) you have to write For 1->A To 7 Step 2 which is really weird.
Casio Isn't that weird. They just wanted to keep the standard assignment operator for the initial part of the for loop, like in other languages where you would say something like for (int i = 0; i < n; i++). It also doesn't require another token.
Arch Linux user
Haskell newbie | Warming up to Lua | Being dragged into C++
Calculators: HP 50g, HP 35s, Casio Prizm, TI-Nspire CX CAS, HP 28s, HP Prime, Mathematica 9 (if that counts)
π: 3.14...; l: 108; i: 105; e: 101; l+i+e: 314
THE CAKE IS A LIE IS A PIE

Offline iconmaster

  • LV3 Member (Next: 100)
  • ***
  • Posts: 82
  • Rating: +5/-0
    • View Profile
Re: Source: A WIP alternate programming language for the Prime
« Reply #68 on: March 28, 2015, 03:11:41 pm »
Hello everyone! It's been a while.

First of all, I updated the original post. It's a lot better now.

Second of all, I'm currently at work rewriting Source from scratch. I'm also contemplating renaming Source (I've got a lot of people saying the name is bad; it kind of is). What do you think?

The drone.io will still have Source version 1 builds if you want them.

Offline chickendude

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +90/-1
  • Pro-Riot Squad
    • View Profile
Re: Source: It's a programming language. Now with HPPL support!
« Reply #69 on: March 29, 2015, 11:57:36 am »
I kinda like the name. If you want to change it go for it, but i think Source is nice.