r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[!Liquid] any questions about liquid dataflow core.

Ammon
7-Mar-2009
[731]
Interesting...  I'm a heavy prototyper.  I need one statement that 
does something to start with and I often have to see each additional 
statement functional before I can move on to the next.  If I spend 
enough time within a given environment I'll eventually be able to 
rebuild it from scratch but your code has always been deceptively 
simple so I often need an explanation of why you do what you do how 
you do it.
Josh
7-Mar-2009
[732]
I really appreciate you making the example for me.  Hope you didn't 
mind the pestering, but it'll be good to finally see this dataflow 
in action
Maxim
7-Mar-2009
[733x9]
I added such comments throughout the code, it should be a pretty 
easy to grasp example, me thinks  :-)
I'm REALLY happy to do it.  its a great opportunity for me to actually 
get some limelight on liquid  :-)
I'll build a second version which has a skill editor  :-)
note, this application doesn't have the aspect-oriented stuff I was 
talking about... just pure liquid dataflow, all based on the !plug 
directly.
also note that liquid was NEVER optimised, so if you look at its 
code, you might find slow loops and such... I know!  for me, having 
it work without bugs and making it easy to maintain, is more important 
than raw speed... in all apps I've done using it, a single View face 
refresh slowed down the application more than alll liquid nodes combined, 
so the integrated lazy computing does enough optimisation on its 
own to make raw optimisation less of an issue.... but when I decide 
to go v2, I will make a "fast" version of the tool for production 
purposes... indentical in features, but with debugging removed and 
some loops optimised for speed.
the shared class, already speeds up the memory handling of the GC 
by a factor of 20 or 100 based on the size of your application (exponentially 
faster, as the app grows)
wow, just realised, I've been improving liquid for the last FIVE 
years !
Blood v0.1.1 released to rebol.org.


the first ever public demo of how to use liquid.  The application 
itself is very simple for now, but the code is pretty clean, has 
a lot of comments to explain a lot of what is going on.
so anyone got questions.... remarks... comments ?  just curious to 
know... I mean its been downloaded MANY times already  :-)
Sunanda
7-Mar-2009
[742]
I've not had a chance to play with it yet, Max.

I suspect many of the downloads will be bots that like to index new 
content.....Not people passing by to check the scripts. New/changed 
scripts get prominent home page billing, so the bots come flocking 
to feast.
Maxim
7-Mar-2009
[743x2]
btw, the name blood comes from an old campaign manager I had built 
several years ago  :-)  (you can even see the links on the .org ML)
would it be possible to filter out bots based on their IP/traffic 
pattern?
Sunanda
7-Mar-2009
[745]
To some extent, yes. We do record counts of "likely human views" 
vs "likely bot views" -- but the stat you see is the sum of the two. 
And the division is not perfect by any means.

I'll slightly reverse my previous statement......The "download this 
script" link is protected by a HTML attribute "rel=nofollow". That 
should prevent well-behaved bots from following the link. So the 
count of downloads is likely to to human rich.
Maxim
7-Mar-2009
[746]
could be nice to see them separate, maybe by adding a "probable bot 
%" next to the counts   :-)
Josh
7-Mar-2009
[747]
I'm still looking through it.  I will modify some parts of it later 
today or tomorrow, and let you know if I have questions
Maxim
7-Mar-2009
[748x2]
I have a newer version which has the "ability modifiers" added as 
extra labels to the right of the abilites... it took me 5 minutes 
to do, and it only needs one new simple !plug derivative:

;- !ability-mod
!ability-mod: make !plug [
	valve: make valve [
		type: 'ability-mod
		;-----------------
		;-     process()
		;-----------------
		process: func [
			plug
			data
		][
			vin [{!ability-mod/process()}]
			plug/liquid: 0
			vprobe data
			if integer? data: pick data 1 [
				plug/liquid: to-integer (data - 11 / 2)
			]
			vout
		]
	]
]


and necessary linkage within the !character setup, and appropriate 
faces in the window layout.
currently preparing 2 liquid modules for distribution on rebol.org 
:
  * LIQUID-VID : adding liquid functionality to ANY vid face

  * GLUE : a (hopefully growing) set of reusable core !plug classes 
   (like !sum and !subtract, in blood example).
Ammon
7-Mar-2009
[750]
Well, I just got home from work.  I'm cooking some dinner which I 
will eat while watching last night's episode of Battlestar Galactica 
and then I will download Blood and play with it a bit.
Maxim
7-Mar-2009
[751]
cool
Maxim
8-Mar-2009
[752x4]
just thought I'd share this list I built while coaching someone in 
using liquid last night...

SANITY PRESERVING KNOWLEDGE WHEN USING LIQUID:
--------------------------------------------


#1:  liquid isn't a bully  - liquid shares its state, but asks for 
data (pulls, observes, etc) from its subordinates ("parents"), not 
the other way around (it doesn' push or force feed, like a highly 
inneficient signal messaging engine).


#2:  liquid is lazy by default - unless a plug or one of its observers 
 ("children") is stainless, nothing will process automatically (thus, 
faces usually are set to stainless, so that they refresh automatically).

#3:  liquid has several computing modes in a single base class.  
  * linking is for once sided dependencies
  * piping is for inter-dependencies or synchronisation
  * containment is for data storage
  * linked-containment is for processed data storage   


#4:  liquid mutates - plugs automatically change computing modes 
when you call some methods like linking, piping and filling.  depending 
on the order of these operations, a plug may "stick" to its previous 
computing mode.  e.g. a piped node remains piped, even you attempt 
to link it to something.


#5:  liquid is alive - remember that as you are setting up a liquid 
network, your plugs will start receiving messages as you are building 
up the tree, meaning that the process() (and other) functions might 
be triggered before every expected connections are done. always verify 
the integrity of the data before starting the process.  (i just got 
stumped by this one again, 5 minutes ago).


#6:  liquid is a collection of droplets - each plug should do one 
thing or manage one step of a process.  the more you break up the 
network, the better you will be at making it stable, reusable, flexible, 
and fast.


#7:  liquid is highly memory efficient - !plug uses shared classes. 
 so all the liquid operations are in a sub-object called a valve. 
 Thus, when you call internal functions, remember they are within 
the valve, and you must supply the plug as its first argument.  my-plug/valve/stats 
my-plug


#8:  liquid is volubile - its slim-based verbose & indented console 
printing engine (vprint) is YOUR BEST FRIEND.  use it profusely, 
to understand the chain of events and what the hell is going on.
SANITY PRESERVING KNOWLEDGE WHEN USING LIQUID:
--------------------------------------------


#1:  liquid isn't a bully  - liquid shares its state, but asks for 
data (pulls, observes, etc) from its subordinates ("parents"), not 
the other way around (it doesn' push or force feed, like a highly 
inneficient signal messaging engine).


#2:  liquid is lazy by default - unless a plug or one of its observers 
 ("children") is stainless, nothing will process automatically (thus, 
faces usually are set to stainless, so that they refresh automatically).

#3:  liquid has several computing modes in a single base class.  
  * linking is for once sided dependencies
  * piping is for inter-dependencies or synchronisation
  * containment is for data storage
  * linked-containment is for processed data storage   


#4:  liquid mutates - plugs automatically change computing modes 
when you call some methods like linking, piping and filling.  depending 
on the order of these operations, a plug may "stick" to its previous 
computing mode.  e.g. a piped node remains piped, even you attempt 
to link it to something.


#5:  liquid is alive - remember that as you are setting up a liquid 
network, your plugs will start receiving messages as you are building 
up the tree, meaning that the process() (and other) functions might 
be triggered before every expected connections are done. always verify 
the integrity of the data before starting the process.  (i just got 
stumped by this one again, 5 minutes ago).


#6:  liquid is a collection of droplets - each plug should do one 
thing or manage one step of a process.  the more you break up the 
network, the better you will be at making it stable, reusable, flexible, 
and fast.


#7:  liquid is highly memory efficient - !plug uses shared classes. 
 so all the liquid operations are in a sub-object called a valve. 
 Thus, when you call internal functions, remember they are within 
the valve, and you must supply the plug as its first argument.  my-plug/valve/stats 
my-plug


#8:  liquid is volubile - its slim-based verbose & indented console 
printing engine (vprint) is YOUR BEST FRIEND.  use it profusely, 
to understand the chain of events and what the hell is going on.
adding a substantial feature to liquid.  the ability to "freeze" 
nodes.  the nice thing is that the freeze state can be set as a function... 
so a node could potentially disactivate itself on the fly, when it 
detects some impending error is about to occur.


it can also stay dead until its dependencies are sufficient... making 
it a highly efficient at preventing useless processing until all 
its dependencies are linked up.
you could even cause its to process only after a time lapse occured... 
automatically preventing useless processing within live animation 
nodes  :-)
Josh
8-Mar-2009
[756]
What is vin / vout?
Maxim
8-Mar-2009
[757x3]
part of vprint system.

vin = vprint/indent
vout = vprint/outdent
they cause the console messaging to go in or out one tab for all 
further vprint/vprobe calls.
this is embeded within the slim manager and is added to any slim 
library automatically
Josh
8-Mar-2009
[760]
That makes sense.   I will be  working on extending your blood to 
be as featured as the other char gen I made over the course of the 
week, so I"m sure I will run into all sorts of fun questions during 
the process
Maxim
8-Mar-2009
[761x3]
the vprint engine I mean... the actual vin/vout code is written manually
just passed all night helping ammon add new functionality to the 
+/- buttons... hehe the learning curve is steep, but gradually flatens.
hense the 8 rules above.... they really explain about 90% of all 
stumps even I fall over occasionally.
Ammon
8-Mar-2009
[764]
So I'm trying to create a plug, !color, that simply forces it's content 
to be a tuple, here's what I thought would work:

!color: make !plug [
	stainless?: true
	valve: make valve [
		type: 'color
		;-----------------
		;-     process()
		;-----------------
		process: func [
			plug
			data
			/value ; faster than:  /local value  
		][
			vin [{!color/process()}]
			plug/liquid: 0.0.0
			unless empty? data [
				if tuple? data/1 plug/liquid: data/1
			]
			vout
		]
	]
]

c: liquify/piped !color
fill c  255.255.255
fill c [0 0 0]



at this point c's content should be 255.255.255 not [0 0 0] which 
it is.
Maxim
8-Mar-2009
[765x2]
one note...  you might want to wait for me to release liquid-vid 
and glue... they will both simplify coding of things a lot.  and 
liquid-vid will even have a few dynamically adjusting faces like 
row and column.


funny thing is that its taking me far less energy (and code) to implement 
more dynamic and smart faces than glayout so far.  its also taking 
a lot less code to do a lot of the same things in glayout.
rule # 7


once you piped the color, processing is by passed.  this is a philosophical 
design decision.
Ammon
8-Mar-2009
[767]
Well, initially I tried it without /piped but FILL threw an error.
Maxim
8-Mar-2009
[768]
pipes and containers are like storage.  their value is to be used 
as-is.  if you wanted to clean ANOTHER plug to a color, your code 
is correct
Ammon
8-Mar-2009
[769x2]
interesting...

p: liquify/piped !plug
c: liquify !color
link c p
fill p  255.255.255
fill p [0 0 0]

does what I want it to.
Sweet.
Maxim
8-Mar-2009
[771x3]
btw, I am now building up a series of sample files for use as a tutorial 
as you guys ask questions and post examples.  so from now on, most 
of the question will be compiled into a great collection, used for 
an eventual tutorial!


so keep the questions comming.  independent and explicit code examples 
like the above are excellent.
exactly.
ammon in the above, the /piped is superfluous  ( and in fact a waste, 
since the p plug only needs to contain data)
Ammon
8-Mar-2009
[774]
Result of the same code minus the /piped ...

>> fill p green
liquid/!plug(1)/fill [
** Script Error: pipe expected plug argument of type: object
** Where: fill
** Near: either any [
    plug/valve/pipe
    plug/pipe?
] [
    plug: plug/valve/pipe/always plug
] [
    plug/pipe?: 'simple
]
Maxim
8-Mar-2009
[775x3]
sorry that is a BUG in liquid! hahahaha discovered it last night... 
well at 5am before I went to power nap.
its fixed and I wonder when that bug got inserted in the first place. 
 there is another tiny bug which I squashed, which was added with 
a brand-new (and not very teste) feature .
what version of liquid do you have on your system?
Ammon
8-Mar-2009
[778x2]
Whatever Blood.r pulled down...  One second...
0.7.0
Maxim
8-Mar-2009
[780]
darn, I just checked... I was sure I had updated the version late 
last night to include the fix... but seems not