Re: [Seed7-users] Q&A
Interpreter and compiler for the Seed7 programming language.
Brought to you by:
thomas_mertes
From: Kobi L. <kob...@gm...> - 2012-08-02 06:10:57
|
On 08/01/2012 04:51 PM, Thomas Mertes wrote: > Welcome. Thanks! > Seed7 can call C library functions, but wrapper functions are necessary > to do it. Some of the types used by Seed7 are different from the ones > used by C (e.g. strings) In this case conversion functions must be > called. I suggest to have two wrapper functions: One that does the > type conversion, error checking, etc. and one that provides a so called > primitive action for the Seed7 interpreter. The primitive action must > also be defined in a Seed7 include library. I started to document the > FFI, but it will take some time. > > In the meantime the existing documentation of the primitive actions at > > http://seed7.sourceforge.net/manual/actions.htm > > can be used to see how a foreign function call can be done. ok, I'll look it up. I think I'll start by learning the language with simple exercises, algorithms or data structures. then, later, probably contribute as I go along. (but let's not promise anything ;-) >> 2) gui - is there a gui library? > Seed7 has a graphics library, but currently there is no gui library. > Except for the Gtk-server connection library provided by Leonardo > Cecchi. I have a plan to have an interface description and to use > this description for a web based interface and for stand alone > programs. But until I get massive support this will take very long, > to be realized. The graphics library looks really cool, from first impressions, it looks suitable for lightweight games and small customized applications. However for commercial development, I assume most users like to see a familiar UI, while the developer would like to not be held back by unimplemented widgets, which is where the mature gui libraries come in. >> It seems portability in the language >> was a main concern, what do you feel about libraries such as fltk, or >> preferrably wxwidgets? (or is there a home-brewn one? do you wish for >> everything to be in one ecosystem?) > Interfacing with a library is okay. I don't know fltk and I have > only little knowledge about wxwidgets. Fitting a gui library fully > into the Seed7 ecosystem is probably not easy. Is it possible to base > a gui library on the Seed7 graphics library? I would like to avoid > event loops in the user program (I hate event loops). I also don't > like redraw events. It is just stupid when the program gets told: > I just deleted your window and you should redraw it. > What would programmers say, when this happens with files? > But this are just my wishes. When you do the work you are allowed > to ignore them. Feel free to add a cgi library to Seed7. I promise > to add it to the release, when it is not buggy and somehow useable. I don't know much about the web so probably cgi support will not come from here. I feel similarly about events. Since they can "jump" up on you, you don't know where they came from, they're not in the code flow, so it's harder to reason and figure things out, especially for a larger program. However what is the alternative? since in a gui application all the widgets are ready to accept input. they are like entities themselves. How would you do that with one codeflow? FWIW, If you're indeed going to implement a whole gui system, based on the Graphics lib, I suggest looking at Rebol's gui dialect, which is the nicest way I've seen for building GUIs. Moreover, maybe you can leverage other's work for example cairo, agg, or clutter. Another promising option is QT's qml, which is an interpreted markup language for ui. (similar to json in structure, css in definition, and has some interaction, and conditional rules). I don't know, however, if you can really make large applications with qml, and still be able to keep things under control. oh, there is also the way fantom do gui's which may be similar to what you want to do on the web. they compile the application both to java for the desktop (or c#, configurable) and to javascript for the web. > >> 3) are functions first class? for example, to define 'map', I would >> pass as arguments, the list and a lambda, or a function name. >> delegates, quotations, lambdas, it has different names. is this >> concept supported? > Seed7 supports a 'map' function, but lambdas are not used. Some half > prepared 'map' function example for the Homepage exists. I just copy > part of this example below. The map function is defined with: > > const func array integer: doMap (in array integer: anArray, > inout integer: aVariable, ref func integer: anExpression) is func > > result > var array integer: result is 0 times 0; > begin > for aVariable range anArray do > result &:= anExpression; > end for; > end func; > > To add 1 to each array element the expression > > doMap(testArray, x, x+1) > > can be used. The map function looks a little bit like a for-loop. > The variable x must be provided as parameter to doMap. hmm.. how does anExpression (inside the for loop) know to take aVariable as its parameter? oh I see, they are just expanded to the external code x and the other x+1. that's quite smart. Is it possible to make map generic? instead of an integer - it would take a T, and return a T array? > >> 4) auxiliary and fancy stuff - >> unit testing (and mocks), > Currently no special support, but I don't see problems. > The functionality of the Seed7 interpreter and compiler is checked > with several programs. I am sure the quality of your code is very high. It's my own feeble mind I'm worried for :-) It helps me to check myself, since if the program gets complicated with time, it's harder to find the source of a bug. In recent years there is also 'tdd' (test driven design) where unit testing has become a continuous and part of the coding process. mocks is about "faking" objects, usually by reflection, creating empty functions and defaulted fields and storing the invocations, so for example, you can test that your client code works, without connecting to the server. since you know what the server is supposed to return to you, you "fake" the server object, returning canned responses that you prepared, and later it's possible to verify what was called, how many times, etc. Sometimes it helps, since you can get the program up and running fast, and then fill all the holes with actual functionality. having a working program is usually easier than waiting until all the code is finished just to test it. Things can get complicated sometimes when a bug was introduced but alot of code was written in one chunk, so which part is good and which isn't? I think mocking mainly arose from object oriented and events, which can get messy. An example library is moq. http://code.google.com/p/moq/ >> design by contract, > Currently no special support >> ADA's argument ranges, > Not sure what you mean with this. Seed7 supports positional > parameters and does not support named parameters. I saw that new version of Ada define ranges for the input parameters as seen here for example: http://en.wikipedia.org/wiki/Ada_(programming_language)#Data_types I think this is a good feature. probably just asserts in runtime, and is basically an invariant (like in eiffel). that's good in order to know that your data didn't get corrupted somehow, and also (as you get the assert) you can know where that wrong data came from. this is basically the advantage for dbc (design by contract) too. it's just a 'requires', that checks the input arguments. 'ensures' that checks the result, and an invariant which isn't in a function but in the class, so it checks the object's state wasn't compromised. >> mixins, > The functionality could probably be provided with Seed7 templates or > abstract data types. >> multiple inheritance, > Not supported >> events, > I already explained, that I don't think that event loops are a good > idea. But nobody hinders you to process events with Seed7. >> fine grained accessibility (not just public private but having syntax >> to limit to a function or class or with wildcards), > Fine grained accessability is currently not supported. Yes, this is somewhat experimental. didn't really expect it. more of a feature request :-) >> actors and network programming ... > Not sure what you mean with this. Seed7 has support for networking > (FTP, HTTP) and CGI. I meant to ask about concurrency, threaded or actors-based, for example in erlang there are lightweight processes, others use co-routines. about networking, I am assuming sockets. Bye and thanks for all the info kobi -- Help stop the persecution of Falun Gong in China. http://www.faluninfo.net |