World: r3wp
[Red] Red language group
older newer | first last |
Evgeniy Philippov 13-Feb-2012 [5003] | Maxim, from a R/S spec: "Red/System ... will be embedded in Red scripts" |
Maxim 13-Feb-2012 [5004] | AFAICT, Red/system is used more like a high-level VM (compilable source rather than interpreted opcodes) which can be natively compiled. RED won't have RED/System semantics. |
Pekr 13-Feb-2012 [5005] | Max, I share some sentiments with Evgeniy. I too don't understand some design decisions - my first take is, that Red/System should be as much compatible to Red, as possible. Hence I will never agree to decision for 'print differing from its Red counterpart. I don't give a <censored> to C users, as imo noone will use Red/system, unless that person also plans to use Red itself. My take is, that compatibility between Red and Red/System is much more important, that compatibility between the Red/System and C. Ditto the strange aproach to use kind of preprocessor for importing the libraries, whereas R2 and World are OK with just make routine! Ditto for strange declaration stuff: declare struct! alias struct! #import for a library Intead of: make struct! make lit-struct! make routine! If Red/System is going to be inlined in Red, the aproach to costructors should be as much the same as possible. This is a dialecting - the same words have different meaning in different context usage. I don't give a <censored> about protecting a possible C user's knowledge ... |
Kaj 13-Feb-2012 [5006] | The print names have nothing at all to do with C |
Pekr 13-Feb-2012 [5007] | It does :-) It does not print newline by default, although it will be 90% time of requested feature. Just because the compatibility to C, Doc introduced print-line, which will be equivalent to ??. So 90% of your time your code is going to be ridden with print-line or ??, becaue we don't like 'prin ... |
Kaj 13-Feb-2012 [5008] | What does that have to do with C? |
Pekr 13-Feb-2012 [5009x2] | That is what I call a protecting C nonsense. We are REBOL, not C, period. I am so mad about it, that if there would not be option to use print along with block, I would stop using Red/System ... |
The decision was based clearly upon the fear, that Red/System is going to be used mainly by C ppl, and that in C print doeas not add new line by default ... that is imo a wrong design decision ... | |
Kaj 13-Feb-2012 [5011x2] | Please point to the "protected" C equivalents |
That is total nonsense | |
Pekr 13-Feb-2012 [5013] | Explain ... that is how I remember the decision point ... |
Kaj 13-Feb-2012 [5014] | Then you remember wrong. It's easy to reread above here |
Maxim 13-Feb-2012 [5015] | Pekr, Red and Red/System don't have the same semantics so I see no reason why they have to be compatible in any way except lexically. |
PeterWood 13-Feb-2012 [5016] | I feel that there is a lot of merit in Evgeniy's approach, not least the possibility of a one-pass compiler. I think it is worth remembering that the current version of Red/System is a "bootstrap" version with which to build Red. Once Red is built, Red/System will be re-written in Red. It is most likely that there will be many imporvements to Red/System , some may involve syntax changes. I feel we should all expect to have to re-visit existing Red/System code when the "real" Red/System is released. |
Evgeniy Philippov 13-Feb-2012 [5017x2] | My approach would also decrease a number of layers by one. This greatly reduces the complexity and greatly improves compilation speed. |
I.e. after each #define and after it the #include, we would need to recompile the included file. That's enourmous lossage of time and resources. | |
PeterWood 13-Feb-2012 [5019] | Whilst I cannot speak for Nenad, I'm sure he will recognise these advantages. He may of course have other strategies up his sleeve to achieve speedy compilation. Whether he would choose to improve the bootstrap version of Red/System at the expense of delaying work on Red is the big question. |
Evgeniy Philippov 14-Feb-2012 [5020x2] | Ok |
But I am sure that NO strategy justifies #include and NO strategy is speedier than IMPORT of a compiled library. | |
Dockimbel 14-Feb-2012 [5022] | Back from my trip to Paris, took me 3 days to come back home (Montenegro) due to huge snow. All roads closed, no train/bus/plane, state of emergency declared since saturday. I will answer the questions brought by Pekr and Evgeniy here later today, when I'll finish reading all the posts and emails I got since a week. |
Pekr 14-Feb-2012 [5023x2] | :-) yeah, we generated quite a lot of a stir here. At least you know, that Red is a lively project :-) |
It all started by me trying to wrap some specific case. That's probably the most importat - Red allowing to wrap more outer world. As for syntax and other sugar, that's a secondary ... for now :-) | |
Endo 14-Feb-2012 [5025] | Welcome back Doc! |
Dockimbel 14-Feb-2012 [5026x4] | Pekr: (short answer) Red/System (and Red) generate executable binaries while R2/R3, while World and all other interpreted languages just run code in an interpreter or VM. This is a big difference, because Red can use the OS to load libraries at "load-time" instead of having to write code to do it (as all others interpreted languages require). This is also faster than loading manually. Red/System doesn't have yet a x-platform extension for adding "run-time" library loading support, just because we don't need it at all for now, but it can be added easily, by wrapping libFFI for example, or implementing it purely in Red/System. |
The only added benefit of manual loading at runtime is being able to upgrade the library without having to recompile the main program. | |
or extending an app by loading "plugins" at runtime. | |
But all the OS and third-party libraries we're currently using in Red/System have stable API, not the need for runtime loading has not appeared yet. | |
Pekr 14-Feb-2012 [5030x3] | We tried to manual load library and get the proc address to be able to wrap a function, which crashes Red (as well as REBOL, World). It might be, that the library is not properly constructed for such a case. But Kaj mentioned something like parameter being a function! type, which is not supported, nor do we know, if it is planned, or if it even help our case .... |
here's what he meant: "get-proc-address should really be defined as return: [function!] but that's not currently supported" | |
OK, so if I understand it correctly, Red/System loads the library at an executable load time, whereas load/library does so dynamically in the app run-time. Stil - I wonder, if we could get a handle to such a library? I mean, syntactically #import is just like preprocessor construct - you can't assign it to any variable. Not sure it would be usefull, to be able to retrieve a handle to such wrapped library plus handles (entry points) to wrapped function calls? | |
Dockimbel 14-Feb-2012 [5033x4] | Evgeniy: (short answer) 1) IIRC, there's no recompilation of included files in Red/System, the only overhead is parsing the preprocessor directives and reducing them. I agree that the whole compilation process would be significantly faster without a preprocessor, but that's another topic. 2) Preprocessor is a handy addition for compiled languages, that's why it was introduced in Red/System, not because it was a planned feature, but just because we _needed_ it for going further. The distinctive # prefix is used to make it clear both for users and the compiler that these parts are reduced at "compile-time" instead of "run-time" and avoid confusing both users and the compiler. For example, from your examples, the compiler has no way to distinguish a "compile-time" IF from a "run-time" IF, unless you make it a lot slower by doing static analysis and complex inference (the cost would be huge compared to the preprocessor). Also, this might also introduce a lot of new restrictions in the language semantics, which is not desirable. 3) IMPORT is better than INCLUDE: you might have missed it, but we can't yet generate libraries, so importing Red/System code now is not an option. |
Pekr: you've mixed up completly "load-time" and "run-time" library loading. You don't need a library handle at "load-time" (unless you want to hack something in the OS). Also, you don't need any of your code above, just the #import declaration with the right function names (finding the right names seems to be the most complex part in the case of the library with the weird API you're using) | |
Pekr: the "make" vs "declare/alias" topic has been discussed lengthly in the ML, please read the posts there. | |
Also, the plan for me since the beginning was to use Red to help construct dynamically Red/System programs without requiring any preprocessor. As Red is not ready yet, I'm glad we have the preprocessor now in Red/System, to make our life easier. | |
Oldes 14-Feb-2012 [5037] | I was not using preprocessor in my Rebol/Flash dialect and I must say, I find the Red/System way useful. It may be true, that additional pass may slow the compilation a little bit, but it also provide additional features. Also I don't expect that it will be used in some huge projects with MB of sources so if it's a few ms slower is not a problem. And as Red/System is open, everybody can provide own version:) |
Pekr 14-Feb-2012 [5038x2] | Doc - we have got the right function names, that is not the problem. The problem is the crash, and we were trying to identify, if Red/System library wrapping system still needs some improvements for some cases, or simply the DLL is doing something internally, that some functions work, and some crash. Here's example: fpGetBright= (LSN_GETBRIGHT)GetProcAddress(g_hLedCtrlInst, "LSN_GetBright"); wrapped as: led-get-brightness: "LSN_GetBright" [return: [integer!]] Btw - how do I wrap properly function, which does not return any result? I tried just without the return clause, but it is not possible. Is e.g. return: [] (empty block allowed?) |
As for compilation time. I don't know guys, but Red/System compiles REALLY fast. I do remember my dos times, where compiling took 30 secs. Where's the problem? It's not imo about the compilation speed, at least for me - it is about the process of building app vs dynamic prototyping using interpreter. I don't like much the compile/build/run process, but I expect something like R2 console for prototyping appear in distant future for Red .... | |
Dockimbel 14-Feb-2012 [5040x4] | Pekr: I will test your lib later today and see what's wrong. As I read that it crashes with also R2 and World, it seems obvious that something is wrong (a) in the lib or (b) you're not passing the right arguments or (c) you're not calling the right functions in the right order. |
Compilation time: absolute speed is not the issue currently, we're talking about relative speed of the preprocessing compared to whole compilation time. | |
it is about the process of building app vs dynamic prototyping using interpreter Well, I don't know how you build apps, I have never built one from the console, but only from a code editor. Console is nice for testing some small snippets when unsure, but coding is usually done in a decent code editor, where you usually launch your script using a shortcut. From that POV, there will be no differences with Red for the users. And to avoid further misunderstanding, Red will have a console, like R2 does, with similar features and possibilities. | |
Btw - how do I wrap properly function, which does not return any result? I tried just without the return clause, but it is not possible. Is e.g. return: [] (empty block allowed?) It's in the spec document and same as the routine! interface in R2, just do not put a RETURN: definition if the function does not return anything: http://static.red-lang.org/red-system-specs.html#section-14.1 | |
Pekr 14-Feb-2012 [5044x2] | Doc - I use text editor too, for some complex stuff.Yet for trial and error I use console. Several users expressed in the past, that one of the nice values of R2 is its console, for the quick prototyping around. |
As for the return value - I was switching between R2, Red, World, so not sure, but ommiting return clause raised an error. Not sure it was Red or other environment. Will try that ... | |
Dockimbel 14-Feb-2012 [5046] | LedCtrl.dll (from ledset-source package): 1) How is it supposed to react if a board is not connected? 2) The DLL is a C++ program with static functions (acting as wrappers I guess). Have these static functions been compiled with an "extern C" directive? If not, there's no chance it can work with anything other than a compatible C++ compiler. I think that the crash has nothing to do with Red/System, the "unknown" error might be caused by the DLL functions corrupting the data segment of the Red/System binary where the runtime error data is located. I will try to track it anyway, just to be sure, it's not a missing code in the Red/System runtime error processing routine. |
Pekr 14-Feb-2012 [5047x4] | I think too, it is not a Red/System. I used the generated exe also on a LED screen PC. I can turn screen on/off, led-is-power? works correctly, ditto for led-is-locked?, but led-get-brightness fails ... so if some functions work, it means that DLL has properly exported values? All use the same declaration ... |
It is a pity that my first attempt has some such problems. Just don't loose the time with it, if you have more important stuff to do. Kaj tried to do his best here, ditto Andreas. | |
Btw - if some func retunrs void, how should my return value look? | |
Also - what is a difference in passing a "void" to func, and passing it no value? Aren't following definitions just the same? typedef void (WINAPI *LSN_BRIGHTDLG)(void); typedef int (WINAPI *LSN_GETBRIGHT)(); | |
Dockimbel 14-Feb-2012 [5051] | Btw - if some func retunrs void, how should my return value look? Void is the C way to indicate "no return value". In Red/System, you just don't add a RETURN: clause in such case. |
Pekr 14-Feb-2012 [5052] | OK, thank, that just clears the situation for me a bit .... |
older newer | first last |