sph-mn / sph-sc

compiles scheme-like s-expressions to c

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Initialize int variable in declaration

arunisaac opened this issue · comments

Hi,

I would like to initialize an int variable in its declaration, like int n = 1. Currently, I can only do this with two forms---a declare and a set---like so

(declare n int)
(set n 1)

Is there some way to do this with just a declare form---something like (declare n (int 1))?

Thanks!

commented

hi,

yes, there is a way - with define.

(define n int 1)

Thanks, I somehow missed that in the documentation. I also just found let* which is useful in some other occasions.

Cheers!