squirrel
squirrel copied to clipboard
Feature idea : Folders
Hi. There is a lack of folder managment in Squirrel. For instance, you can't list a folder's content. As C's standard doesn't support folders (IIRC), it could be interesting to provide a compilation-time toggable module so one can opt in folder support or disable it. It could be disabled by default to stick to C standard compliance. I have some ideas of implementation but I wanted to see if you were interested in such module or not.
Have a nice day!
this should be be in a library, one of the things I'm tinkering about is a standard way to load libraries. My target is to keep the core distribution as small as possible.
If you're meaning DLLs, etc., then I must say, I think lua's implementation of that is one of it's biggest failures. It's meant to be embedded and customized, yet people toss around dlls built against an unknowable library's internals, referencing other dlls with bizarre, messed-up names, and making themselves hard to static link. It's a huge mess. Sure, it's useful for individual projects to load their own modules, but it's even more useful for creating a botched-up ecosystem. It's irresistable.
It's possible you could improve on this by making a kind of stable "ABI" by having libraries take a struct of function pointers which it should use: sq_abi->sq_poptop(v) instead of sq_poptop(v).
Somewhat related: I've been thinking about lua's concept of 'power patches' and how it would be neat if that could be formalized. To the extent that a tool might have a registry of known power patches and compatibility data which could then be used to assemble a squirrel codebase with the desired list of patches.
This could be an alternative for relatively lightweight libraries like the filesystem stuff. But heavier-duty stuff really needs its own build systems.
Also, the issue I see with DLLs are the target platforms that ight not support dynamic link loading (like the Ti-Nspire which hosts my fork of squirrel destined to offer another way to program games on these calcs).
I don't know what @zeromus means by power patches, but I'd see somethings like define/variable based folder addition to the source code used to make the interpreter, it'd offer some kind of flebility and wouldn't impact so much the performances and the portability than DL, IMHO.
http://lua-users.org/wiki/LuaPowerPatches I can't do much to explain it better than this. Basically it's just big features that are kind of questionable to include in the core distribution but which can be merged together to create a customized squirrel with few problems due to their individual independence and design being as lightweight as possible.
In most, if not all cases, a dll-inspired approach for loading modules can be subverted for static linking on a case-by-case basis. It's still annoying, although it could be less annoying if that scenario was planned for from the outset.
I written a lib back in 2003 (squirrel 1.0) that did allow "sq_abi->sq_poptop" for dlls and static libraries at the same time by using a set of defines like this "#define sq_poptop sq_abi->sq_poptop ". I have to dig it out.
On Linux, we have scandir, readdir, and opendir in C, which is what I chose to loosely base folders in my squirrel extensions on.