Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - iconmaster

Pages: [1] 2 3 ... 6
1
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.

2
HP Calculators / Re: Change the screen color?
« on: March 06, 2015, 04:24:25 pm »
Go into Home Settings. On the second page, go to "Color Theme". Toggle it.

Congratulations! You've switched from light background to dark. I personally like the dark scheme better, and suggest you use it.

3
HP Calculators / A Quine in HP Prime
« on: December 03, 2014, 05:33:40 pm »
Just a little something for the lulz. Name the file it goes in "QUINE", of course.

Code: [Select]
EXPORT QUINE()
BEGIN
 MSGBOX(Programs["QUINE"])
END;

While I'm at it, have a program (named SELFMOD) that stores a variable, but never uses the := operator to store new values in it:

Code: [Select]
x:=0;

EXPORT SELFMOD()
BEGIN
 MSGBOX("x is "+x);
 Programs["SELFMOD"]:=LEFT(Programs["SELFMOD"],3)+(x+1)+MID(Programs["SELFMOD"],INSTRING(Programs["SELFMOD"],";"));
END;

4
HP Calculators / Re: New HP Prime OS Version: 2014.1124
« on: December 03, 2014, 04:53:09 pm »
HOLY HECK. A new update! Well, let's try out what's new...

On update, I get... A lock screen. An... Unexpected change. I don't really understand why it was included.

Well, first of all, it seems out prayers of data persistence have been answered. We can now write/read data from notes and programs programmatically! This really opens up a lot of frontiers if you think about it.

Notes is a weird variable. For instance, to get the names of all notes in the system, you have to copy Notes to another variable. No copies are involved if you just want the contents of all notes in the system, however!

Also, why are newlines scrubbed out when reading/writing?? They are kind of important. EDIT: Scrubbing doesn't happen in programs for some reason. Okay.

I'm kind of sad text formatting is lost when doing stuff with notes, but eh. Whatever.

The other new variables are super nice as well. Could be useful.

I can't get #cas/#end to work yet. I'll figure it out soon, I bet.

Also, regarding the conn kit: It does look a lot better. That's nice.

EDIT: Creating a new program via Programs crashes, it looks like. I'm using the emulator to test, though, so that might be why.

5
About the 1+1="" bug: I reset my device, and it went away. It comes back sometimes, though. I can't even begin to fathom it.

ANYWAYS. Some questions which are probably feature requests!

I was looking at the IFERR block, and I can't find a mechanism to gather information about what caused the error. I though such a thing existed; the help file for TYPE talks about an error data type. Am I looking for something that exists?

Also, #pragma is interesting. Is there any other uses for it other than separators and integer settings?

6
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!

7
HP Calculators / Re: TETRIS for the HP Prime!
« on: November 17, 2014, 10:48:39 pm »
Question: Would you mind if at one point I modified this game to include more advanced graphics? I like this version in particular so I thought that spicing it up with sprites and such stuff as replacement to plain color squares would be nice.

Go right ahead. I'd be glad to know I've helped you make something even better!

8
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.

9
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
}
}

10
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)
}

11
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.

12
Multiple dispatch?

Source uses static dispatch, but yes, it does dispatch now.

Anyways, I've been working for HPPL drawing emulation in SourceBox. It's limited, but for now you can run this program in both the Prime and on your PC:

Code: [Select]
import prime.draw
import prime.io

@export
function 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.")
}

13
I implemented the libraries for drawing in HPPL.

Code: [Select]

import prime.draw
import prime.io


@export
function 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.")
}

14
I'm guessing the FFI is not going to be platform independent. Am I sensing compile-time code selection?

Yes, the @lang strings are platform-dependant, as well as @native. However, I plan on making a few @langs that are independent, such as ones for Source internal bytecode.

Basically, there is a bytecode operation called NATIVE which contains the @lang string. The platform assembles this operation however it wishes; in this case, the HPPL platform takes @lang=hppl blocks and inserts the contents directly into the HPPL output.


Moving on...


Today, I have for you more progress! We now have function overloading. Now you can have two functions with the same name and different arguments, like so:


Code: [Select]

@export
function overloadTest() {
print(func())
print(func("an argument"));
}


function func() {
return "Got no arguments!"
}


function func(a) {
return "Got "~a
}


Overloading via data type will be supported soon. Right now, however, I have made directive-based overloading, too.


So, in SourceBox, you have an output panel where calling print is like the standard println. Well, what if you want a newline-less print? Well, in SourceBox, there are two versions of print. They both take 1 argument, but one of them is tagged with the @append directive. Because of this fact, you can target the print-like one instead of the println-like one as so:


Code: [Select]

@main
function printTest() {
print("This ends with a newline.")
@append print("This one ")
@append print("does not.")
}


If you tag your function call with a directive, it will try to match the directives up between functions. This way, you can have a very fine way to control function call overloading.

15
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.

Well, right now, SourceBox is a rather... Naive implementation. For one, in SourceBox, lists start at 0 and are passed by reference...

For one, I plan on having other compiling platforms; platforms where things are passed by reference and where arrays are indexed by different things.
I have plans to alleviate this divide; for example, I plan on making Source a language where the first list index is irrelevant. Wait and see to find out how!

In other news, you can insert HPPL code directly into Source programs:

Code: [Select]
@export
@!optimize
function hax() {
   local a="HAX"
   @lang=hppl "msgbox(a)"
}

Also, you can use custom HPPL functions as Source functions:

Code: [Select]
@native=MAX
function wow(a,b) {
   
}

@export
function getmax() {
   return wow(1,2)
}

Code: [Select]
@native
function MAX(a,b) {
   
}

@export
function getmax() {
   return MAX(1,2)
}


You can also use @lang to comment your compiled output:


Code: [Select]

@export
function stuff() {
@lang=comment "This function does stuff."
print("Stuff done!")
}

Pages: [1] 2 3 ... 6