Hi Dimitris, As someone currently learning to use Slang (i.e. not an expert), I've added my 2c below...
On Wed, 17 Oct 2018 at 11:06, Dimitris Chloupis <kilon.al...@gmail.com> wrote: > > Thierry you have done it !!! you just gave a very easy solution to my > problems. > > Yeap Slang is quite close to what I am thinking, unfortunately Clement told > me to stay away from it because the code is ugly and specially used for VM > only. If I remember also correctly it does not generate readable C code > either. But the idea as a concept is very close to what I imagine. I've found the C code produced to be quite readable, but that is probably influenced by the fact that I have read the slang first. > As a matter of fact you mentioning Slang made I have an epiphany that I dont > have to create a new syntax at all, instead I could use specific variables or > methods to provide type annotation. Thus like Slang I can use regular > Smalltalk code that avoids changing types but without the need for type > inference (although I am not excluding this either). > > So yes I am definetly want to move to the direction that Slang goes so I can > fully utilise the Pharo IDE and minise code that I have to write. > > So basically I am thinking write code as you always write in Pharo and either > a) Have special dictionary variables in each method that provide static type > annotations for the arguments of the methods, its return type and local > variables Slang uses method pragmas to define the variables types. This seems to work quite well. > b) Have special methods that provide such dictionaries seperately. > > Or probably both. This way I can write 100% Smalltalk code and use a very > small compiler to read those dictionary variables for the type of the > variables and functions/structs (essentially a class will be output for a C > struct with pointers to functions for methods and variables for instance > variables). Why invent a whole new language when everything I need already > Pharo provides ? > I could also use special variable dictionaries for all sort of things like > generation of header files, generation of CMake files for automatic building. > > Also I like to use the way UFFI is doing C function signatures by using > symbol arrays. > > So thank you all for inspiration it looks like all I need is Pharo AST > methods (which I can from the AST packages) and SmaCC. > So yeap looks like Magnatar will be a new Slang afterall, I will keep you > posted. > > Also this also opens the possibility of autowrapping the generated c code > back to Pharo through UFFI, so one can use C code as if its Pharo code. I can > leverage the TalkFFI project that does this already. Seems all the pieces > have fallen in their place. > > Keep the suggestions and advice coming, you guys are inspirational :D Do you intend that the Smalltalk code can be executed? This will likely increase the complexity quite a bit. In the VM simulation we end up creating a XSimulation subclass that provides the framework for executing the smalltalk code, e.g simulating functions that are only in C. There is also the problem of platform differences. Slang doesn't really handle them well (pragmas can be used to indicated that methods should only be compiled on certain platforms, and #ifdef type code can be used, but it isn't enough). It would be nice to have a class that provides cross platform functionality, and then platform specific classes as required. HTH, Alistair