PeterTillema / ICE

ICE Compiler for the TI-84 Plus CE
22 stars 1 forks source link

Programs-as-procedures #149

Open s5bug opened 4 years ago

s5bug commented 4 years ago

I want to make a library for BigInts/BigRationals/BigDecimals, and I need to perform certain mathematical operations with them. I was thinking that a way to implement "subroutines" would be to allow programs themselves to accept arguments and then be able to call those programs from ICE, for example: SNBICMP:

[i]INBICMP(BIGINTA,BIGINTB)

[i] some code here
SOMEMATH+SOMEOTHERMATH->RESULT
[i] some code here

RESULT

SNBIADD:

[i]INBIADD(BIGINTA,BIGINTB)

[i] some code here
prgmSNBICMP(MYBIGINTA,MYBIGINTB)->CMPRESULT
If CMPRESULT=-1
    SOMEMATH+SOMEOTHERMATH->RESULT
Else
    SOMEFOO+SOMEOTHERFOO->RESULT
End
[i] some code here

RESULT

I have another idea on how to handle parameters that I'll post in a separate issue.

AlvajoyAsante commented 4 years ago

I strongly agree with this!! But it needs to be approached in a new way.

Instead of having a separate program that allows you to run new command. it should be in source code of the program like in C.

This makes it much more easier and less space consuming. not only will this help, this will put an end to people asking for new commands in ICE. 😄 "Just A step closer to ICE 3.0!"

s5bug commented 4 years ago

I agree that that's also a good idea, but (with my very limited knowledge of how ICE works) it seems like it would be harder to implement.

I think if it does end up being handled that way, having imports would be a great idea. I'd be able to fit a math library into a single program that others can just import.