World: r3wp
[Rebol School] Rebol School
older newer | first last |
Janko 16-Apr-2009 [2722x2] | if I have rebol object R2 >> A: make object [ add: func [ ] [ .... ] remove: func [ ] [ ....... ] parse-rule: [ ..... ] ] B: make A [ change: func [ ] [ .... ] ] << and if I make 100 objects like B from A ... does this mean each of them has it's own "add remove parse-rules" copy in memory or there is just one copy of these functions/blocks that they share it? |
it seems it makes copies | |
PeterWood 16-Apr-2009 [2724] | I believe you are correct. There is no separate "prototype" in Rebol. |
sqlab 16-Apr-2009 [2725] | You can use this method, if you don't want to get copies A: make object! [ add: func [ ] [ .... ] sub: make object! [parse-rule: [ ..... ] ]] then the elements in the subobject are just references. |
Janko 16-Apr-2009 [2726x6] | I was away... I tested on these 3 cases... started new rebol each time, it took 13MB of ram at start A: make object! [ a: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" b: [ 123 1231 13 123 12313 1 2312 3123 123123 12 231 21 312 12 123 31231231 2312 312 1231 2123 123 12 3123 12 312 312 312 312 31 23 123 123 12 312 31 23 123 12 312 312 3 123 12 312 31 23 123 12 312 3 123 12 31 3 123 13 12 123 123 12 3 123 1231 23 123 123 12 312 3 123 12 312 3 123 12 312 3 123 12 31 23 123 12 31 23 123 1 23 123 12 31 2 23 12 3 1 3 12 312 3 123 12 3 ] ] AS: copy [] loop 100000 [ append AS make A [ ] ] went to 250MB RAM -- A: make object! [ a: does [ print "something" a: 2 + 3 + 5 loop 10 [ print "a" ] ] ] AS: copy [] loop 100000 [ append AS make A [ ] ] went to 50MB of ram -- A: make object! [ a: "" ] AS: copy [] loop 100000 [ append AS make A [ ] ] went to 25MB of ram -- |
sqlab - I will try what you say.. I asked because at the actor lib I am making each actor/thread is one object so I want to have them as lightweight as possible | |
( It is understandable why is this , block (like parse block or block of code) , and also func in rebol body is just "data" and you can change it in each instance ) .. | |
sqlab - bravo! your trick works.. A: make object! [ proto: make object! [ a: does [ print "something" a: 2 + 3 + 5 loop 10 [ print "a" ] ] ] ] AS: copy [] loop 100000 [ append AS make A [ ] ] went to 21MB ram --- I have to see what this means to inheritance and other things | |
I also tried this but it works the same as if I define block in object A-a: [ print "something" a: 2 + 3 + 5 loop 10 [ print "a" ] ] A: make object! [ a: does A-a ] AS: copy [] loop 100000 [ append AS make A [ ] ] | |
sqlab: hm.. but do you know for a way that subobject could access parent's objects data? | |
sqlab 16-Apr-2009 [2732] | You have to give the parent object as a parameter to the functions in the sub objects, then you can acces the elements as pobj/name |
Janko 16-Apr-2009 [2733x5] | I tried this.. but self in that context is the subobject ... actor-static!: make object! [ parent: none act-match: copy [] act: [ match-do take mbox act-match ] test: [ print parent/mbox ] mode: 'm ] actor: make object! [ mbox: copy [] vars: copy [] static: make actor-static! [ parent: self ] ] |
hm.. but act are blocks of code .. not functions right now so they don't have params | |
so they can be used like this... this is how it currently worked (without static) ... cat-boss: make actor [ act-match: [ [ still-seeking ] [ print "cat boss: our cat agent is still seeking!!" ] [ found-fish ] [ print "cat boss: yeey, we found a fish!!" ] ] ] ... anyway, thanks for your help so far a lot! I need to start my brain, it seems it doesn't work very well today | |
aha, this works, thanks to your ideas. actor-static!: make object! [ parent: none act-match: copy [] act: [ match-do take parent/mbox act-match ] test: [ print parent/mbox ] mode: 'm ] actor: make object! [ S: self mbox: copy [] vars: copy [] static: make actor-static! [ parent: S ] ] | |
ah, I am stupid is actor-static is just one for 100 copires than parent can't only point to one parent so this won't work | |
sqlab 16-Apr-2009 [2738] | Unfortunately i do not understand, what you do with your actors. |
Janko 16-Apr-2009 [2739x4] | http://itmmetelko.com/blog/2009/04/12/playing-with-making-an-actor-like-distributed-system-in-rebol/ ... I am thinking that I won't change it all and make usage more ugly becase right now I don't even know If I will ever need to have 100000 actors running.. so for now I will continue using object and try to make it elegant without worying about this |
(again , it hot distorted) ... I am thinking that I won't change it all and make usage more ugly becase right now I don't even know If I will ever need to have 100000 actors running.. so for now I will continue using object and try to make it elegant without worying about this | |
hot = got | |
I need to see more how this is used before I start optimising, I thought I can make some optimisation without complicating it all up and make it less elegant to use and extend | |
TomBon 16-Apr-2009 [2743] | hi janko, have you seen the erlang concept of concurrent distributed programming? http://erlang.org/doc/getting_started/part_frame.html perhaps you can find there some additional ideas. A robust and complete p2p component in rebol would be fantastic. |
Janko 16-Apr-2009 [2744] | TomBon ... yes , erlangs actors are the inspiration for this, although I don't have plan to mimic them entirelly .. actors/processes there are main building blocks of app in erlang, you can have many thousands of them , spawn them all the time etc.. here so far my goal is more to use them for distributted computing part, communication between various processes/computers ( I have servers that need to talk to bots etc.. and back) |
sqlab 16-Apr-2009 [2745] | Do I understand that you want to send actors a message and they should act upon the elements of an objects of the sending process? |
Janko 16-Apr-2009 [2746x2] | no no,... upthere I was trying to make actors lighter... each actor is a object now , and each carries around code in it's methods so it's not as lightweight as it could be.. but this is more of a theoretical probem for now.. as I said I am more interested in them for distributted programming so I maybe won't be spawning and having 100 000 actors around like in erlang for ecample |
I will post new version with some updates in few days, it will have some similar pattern matching/deconstruction for messages, remote actor spawning too, actors could remove themselves, and hopefully some solution for addressing actors more elegantly by then | |
TomBon 16-Apr-2009 [2748] | interesting project janko, will follow your updates. |
Janko 16-Apr-2009 [2749x2] | thanks Tom, I hope something ok will come out of it :) |
if we would need really lighweight actors they would have to be made with blocks so that they would hold just data , .. rebol creates 1.000.000 blocks with key and empty string in 4 sec and 70MB, but it is question if this is really needed, with objects you can very nicely as normal objects extend them into new types of actors | |
TomBon 16-Apr-2009 [2751] | for this small overhead you buy objects which are much better and flexible. |
sqlab 16-Apr-2009 [2752] | I am not sure if this can help, but you can get objects with references instead of copies, when you modify them after creation. maybe like this >> template: make object! [ [ a: 1 [ b: 3 [ c: "times" [ ] >> >> obj1: make template [ [ a: 2 [ b: 4 [ c: none [ f: does [print [ a c b "gives" a * b] ] [ ] >> >> obj1/c: template/c == "times" >> >> obj1/f 2 times 4 gives 8 here c is just a reference, not a copy >> |
TomBon 16-Apr-2009 [2753] | It is not 'everytime' wise to look for the smallest possible. funcionality is the key here in my opinion. |
Janko 16-Apr-2009 [2754] | sqlab .. you are a real object magician :) ... not sure either if this can help me right now but good to know for this |
Anton 20-Apr-2009 [2755] | On 19-Feb-2009 in this group I said that Tiny C Compiler (TCC) had problems. Well, I tried again using the latest version from git repository and successfully created a shared object library which can be accessed by Rebol. So, Vladimir's tunel.r code, which I ported to C, can now be compiled using TCC (as well as GCC). This is good because TCC is much smaller (and faster) than GCC and can hopefully be integrated in nice, small cross-platform packages. |
Steeve 20-Apr-2009 [2756] | Nice anton, I hope we'll see your work soon... |
amacleod 20-Apr-2009 [2757] | Is that the answer to rebcode in R3? |
Pekr 20-Apr-2009 [2758x2] | I doubt that, unless it is available to all the platforms. Also - Anton - how "big" it is in terms of KBs it would add to REBOL executable? Is it under 100KB? :-) Because if not, Carl might not consider it :-) But who knows, R3 is going to have plug-ins, so it might be as kind of external "rebcode" engine. The first thing I woudl probably do is I would consider ASM/JIT, Blit/JIT addition (not sure it is cross-plaform either though) |
I wonder what would be the option? REBOL would found out there is a "rebcode" in it, it would be a C code, and then your app would have to compile and link it in order for being able to execute it? Could there be a precompiled (or compile at first run) option? Because if not, then it would be slow, no? | |
Anton 20-Apr-2009 [2760x2] | Well, the TCC binary here is 129ko. I don't think Carl will be adding it to the Rebol executable, anyway. The trick, I think, is to have a simple set of instructions to install TCC ready to use with Rebol. |
After that, I suppose it could grow into a plugin. | |
BrianH 20-Apr-2009 [2762] | The plugin model should be compatible with a wide variety of licenses, so there may be better candidates for this kind of thing. Most of the other languages in REBOL's class are working on LLVM, CIL and JVM backends, but those are all pretty large. Perhaps libjit now that it is LGPL - that would be a plugin-compatible license, I expect. |
Janko 20-Apr-2009 [2763] | I got to Cyclone from the tcc website.. does anyone have an oppinion on this ? http://cyclone.thelanguage.org/it seems interesting to me |
BrianH 20-Apr-2009 [2764x2] | There are several "safe C" languages out there. Cyclone looks interesting, but hasn't been updated since 2006. |
I'm interested to see who gets there first: The languages that try to graft safety and high-level features onto C (Cyclone, Vala, ...) or the efforts to speed up languages that already have the safety and high-level features. | |
Steeve 20-Apr-2009 [2766] | Any chance to see your current work or how you configurate TCC for Rebol , Anton ? |
Janko 20-Apr-2009 [2767] | BrianH, yes interesting question... ocaml is closing in to c if you want FP, Java speed-wise also but has a bigger ram usage and startup times I guess. but it's also hard to say "what is the high level" that we want. Is it Java like, is it dynamic langs, is it FP |
Anton 21-Apr-2009 [2768x3] | Steeve, try this: do-thru http://anton.wildit.net.au/rebol/os/nix/draw-tunnel/demo-draw-tunnel.r |
(Actually, you need to read this file first, and follow Usage instructions to install TCC first. Then you can do-thru as above..) | |
(I didn't figure out how to bundle TCC standalone yet.. just a few experiments, so that's why you need to install TCC to the system.) | |
Steeve 21-Apr-2009 [2771] | Hmm, Anton, i can't figure where is your source of draw-tunnel.c Can you give a direct link, please ? |
older newer | first last |