0 Members and 2 Guests are viewing this topic.
function types() { local a as real //a is of type real local b as string //b is of type string //a = "" //real!=string, ERROR! b = "" //string==string, fine a = 1 //fine //b = 1 //ERROR! local c //c is ??, which is the base type (?) weakly typed c = 1 //fine, c is now of type real?, again weakly typed c = "" //fine, c is now type string? local d = 44 //d is of type real? a = d //real==real?, fine //b = d //string!=real?, ERROR! d = "" //real?==string?, fine local e as ? //e is ?, the base type, but strongly typed e = "" //you can set anything to e //... But the reverse is not true. //b = e //string!=?, ERROR! d = e //??==?, fine}
I still plan on buying a Prime one day. This will be one of the first programs to run on it. Once I buy it.
I'll definitively have to try Source at one point too, although since I prefer to not learn multiple languages at once I'll most likely stick to PPL at first, but if I keep running into roadblocks or can't stand it, I might attempt a switch to Source.Anyway keep the good work on this. If this do come to fruition this is definitively front page material I'll be suggesting to staff.
@exportfunction powers() { @inline local end = 10 print("The first "~end~" powers of 2 are:") local i,a,b = 0,0,1 while i<end { a = a + b b = a print(b) i+=1 } print("Done!")}
Wait, so basically if I want to make a game for both the HP Prime and the computer at once then I now can if the computer language is available for Source?
Quote from: DJ Omnimaga on November 06, 2014, 06:41:49 pmWait, so basically if I want to make a game for both the HP Prime and the computer at once then I now can if the computer language is available for Source? Yes.Of course, Source still needs a library for drawing...
That's amazing. I wonder if PC programs will run as they do on the Prime, especially for compiled languages? It would definitively make things even easier (although you would need of course good support for the TICKS and WAIT commands so we can make our games run at constant speed. And yeah drawing will definitively be a must, especially with how much freedom HP PPL offers already.
@export@!optimizefunction hax() { local a="HAX" @lang=hppl "msgbox(a)"}
@native=MAXfunction wow(a,b) { }@exportfunction getmax() { return wow(1,2)}
@nativefunction MAX(a,b) { }@exportfunction getmax() { return MAX(1,2)}
@exportfunction stuff() { @lang=comment "This function does stuff." print("Stuff done!")}
I'm guessing the FFI is not going to be platform independent. Am I sensing compile-time code selection?
@exportfunction overloadTest() { print(func()) print(func("an argument"));}function func() { return "Got no arguments!"}function func(a) { return "Got "~a}
@mainfunction printTest() { print("This ends with a newline.") @append print("This one ") @append print("does not.")}
import prime.drawimport prime.io@exportfunction main() { local a = [rgb(255,0,0),rgb(0,255,0),rgb(0,0,255),rgb(255,0,255),rgb(0,255,255),rgb(255,255,0)] screen.clear() screen.drawString("Press any key to begin.",20,10) waitForInput() local i = 1 while not isKeyDown(4) { screen.fill(a[i] as real) screen.drawString("Source",125,40,7) wait(.5) i+=1 if i>a.size() { i = 1 } } msgbox("Source. It's a programming language.")}
Multiple dispatch?
import prime.drawimport prime.io@exportfunction main() { local a = [rgb(255,0,0),rgb(0,255,0),rgb(0,0,255),rgb(255,0,255),rgb(0,255,255),rgb(255,255,0)] screen.clear() screen.drawString("Press any key to begin.",20,10) waitForInput() local i = list.start while not isKeyDown(key.esc) { screen.fill(a[i] as int) screen.drawString("Source",125,40,7) wait(.5) if a[i]==a.last() { i = list.start } else { i+=1 } } msgbox("Source. It's a programming language.")}