albertodemichelis / squirrel

Official repository for the programming language Squirrel
http://www.squirrel-lang.org
MIT License
894 stars 148 forks source link

How to use C language include "test.nut" similar function #256

Open 9844201 opened 1 year ago

9844201 commented 1 year ago

I like it so much How to use C language include "test.nut" similar function

albertodemichelis commented 1 year ago

you need a C preprocessor

zeromus commented 1 year ago

You could implement preprocessing in squirrel, too! Only the person feeding a script to the compiler truly knows how to find other referenced scripts. But it might be good if squirrel had a way to set #line and #file for producing debug data. Not that I'm suggesting it, just thinking out loud.

albertodemichelis commented 1 year ago

I though about it a number of time #include is propably not a good idea to be built in in the language. However #line and #file would be very useful for a DSL that spit out squirrel and wants to retain debugging.

albertodemichelis commented 1 year ago

I think the major issue is that the dubug information as is now, assumes 1 source file per SQFunction.

RizzoRat commented 1 year ago

maybe allow #include only outside any class or function - or generally bracket closure? (The main problem why we implemented a workaround-include are ENUMs and constants, whereas constants at least have their consttable, ENUMs are bound to compilerruntime and hence just don't work across files at all - so we now can "include" them)