From: Dave Hayden on
I have uploaded to hpcalc.org an HPGCC library that provides easy
access to all 30+ types of RPL objects. I've found that with the
library, I can cut down on RPL wrapper code for HPGCC programs. For
example, the old version of my sudoku solver took 2-3 seconds, mostly
in a wrapper that converted a matrix to a string for input to the C
program, and converted the resulting string back to a matrix for
output. The new C code reads/writes the matrix directly and runs in
0.1 seconds. It took about 20 minutes to make this change.

This library takes a different approach with lists and other compound
objects. Rather than making a copy of the object in the C domain, it
provides functions to iterate over the Saturn domain object. When
dealing with large lists, this can save a lot of memory. By focusing
directly on the objects, stack manipulations become trivial: STACKpush
() and STACKpop() will push/pop any object.

Indirect pointers in composites are handled robustly.

Here's the link. Full source code is included. It can be recompiled
to work on the 48gii with HPGCC 1.1.

http://www.hpcalc.org/details.php?id=7177
From: Dave Hayden on
On Feb 1, 9:57 am, Dave Hayden <d...(a)larou.com> wrote:
> I have uploaded to hpcalc.org an HPGCC library that provides easy
> access to all 30+ types of RPL objects.  

Did I mention that this was a 0.1 beta sort of release... :)

I've found a couple of bugs in further testing. If you want to try
this library, please contact me for the latest version. I'll upload
bug fixes to hpcalc.org after some more use/testing.

The good news is that the library makes RPL wrappers almost
unnecessary. I've been playing with Egan Ford's tutorial and with the
help of this library, the "N-panes" code can run 15x faster.

Dave

From: hughserious on
Hi,

I've been having a look at this library. it's really handy for
interfacing Saturn objects to C and back. do you know how i might
raise C errors as saturn errors. for example, divide by zero, or some
other math error.

i might have a go at the matrix & list bits next.

thanks,
-- hugh.
From: TW on
> I've been having a look at this library. it's really handy for
> interfacing Saturn objects to C and back. do you know how i might
> raise C errors as saturn errors. for example, divide by zero, or some
> other math error.


/// STORE SATURN ERROR CODE
void
errorsto(int errno)
{
sat_poke(SAT_ERROR, errno, 5);
}

errno is some error number. Just match up the decimal value with your
desired error message, and then you are good to go. You would have to
display the error in saturn land, but it is trival to set the error.
Works great for librarys too!

TW
From: hughserious on
On 5 Feb, 22:42, TW <timwess...(a)gmail.com> wrote:
> > I've been having a look at this library. it's really handy for
> > interfacing Saturn objects to C and back. do you know how i might
> > raise C errors as saturn errors. for example, divide by zero, or some
> > other math error.
>
> /// STORE SATURN ERROR CODE
> void
> errorsto(int errno)
> {
>     sat_poke(SAT_ERROR, errno, 5);
>
> }
>
> errno is some error number. Just match up the decimal value with your
> desired error message, and then you are good to go. You would have to
> display the error in saturn land, but it is trival to set the error.
> Works great for librarys too!
>
> TW

Awesome! thanks very much, that's just what i need.