On 9/8/06, Martin Bähr <[EMAIL PROTECTED]> wrote:
> On Fri, Sep 08, 2006 at 04:37:39PM +0200, Axel Liljencrantz wrote:
> > In the end, it seems to me like variables and functions are a bit like
> > each other, but not enough that they should be merged.
>
> have you considered merging in the other direction?
> ie: have each client simply write their universal variables to the file,
> and have others pick it up from there? this would be a bit slower, but
> it might eliminate the need for fishd. (i don't know what else fishd
> does though but in general i do find that fish and fishd communicate more
> than should be needed)

Sharing variable values requires some form of
inter-process-communication. Fishd uses a socket, but it would
certainly be possible to use the filesystem as an IPC mechanism
instead. The main advantages I see with sockets are:

* Speed - since nothing needs to ever touch the hard disk, this will
probably be noticeably faster. On a 300 MHz system, the time taken by
fishd communications is not negligible. Since I haven't actually
implemented the filesystem-based solution, so I don't know how large
the speed difference would be, but keep in mind that you'd need to
stat a whole bunch of files for every single time a universal variable
changes value. Not good. This is not really an issue with shellscript
functions, because they rarely change, you can just do a single stat
of the main directory every once in a while to make sure everything is
ok.

* Predictability. Because of the way the communications are done using
fishd, you are guaranteed that once the call to set a new value for a
universal variable returns, all other commands starting after that
point in time will always only use the new value. That is the reason
why fishd is much more chatty than you would think it had to be. I
don't know what guarantees you can get with a filesystem-based
approach without completely losing performance, but I'm not sure I'd
want to find out either. I think that offering _some_ form of
guarantee on when a variable update is delivered is very important if
you want to use universal variables in scripting.

>
> > 'function -S foo; echo bar; end' vs. 'function foo; echo bar; end;
> > save_function foo'.
>
> well, i just went through the steps of creating a function, on
> the commandline and then saving it to a file.
>
> i did it as:
> function foo; echo bar; end
> testing foo
> echo "function foo; echo bar; end" > ~/.fish.d/functions/foo.fish
> edit the file to add linebreaks
>
> the thing with this is that 'save_function foo' would ensure that the
> function you previously defined, is the one being saved, and not a
> potentially different version of it. (in the above case i had variable
> references which were expanded, and i had to go back and fix that)

Sure, and the implementation is pretty easy, too:

function save_file
    for i in $argv
        functions $i >/SOME/PATH/$i.fish
    end
end

>
> on the other hand, i find that since functions are autoloaded, the
> following proccess works equally well:
>
> edit ~/.fish.d/functions/foo.fish
> save
> test
> edit...
>
> ie: no need to use the thight commandline at all.
> though the commandline is convenient if you want to turn a previous
> non-function commandline into a function.

That is exactly the use case I imagined for this function. Maybe it's
too rare for it to be motivated to have this functionality built into
fish.

>
> greetings, martin.
> --
> cooperative communication with sTeam      -     caudium, pike, roxen and unix
> offering: programming, training and administration   -  anywhere in the world
> --
> pike programmer   travelling and working in europe             open-steam.org
> unix system-      bahai.or.at                        iaeste.(tuwien.ac|or).at
> administrator     (caudium|gotpike).org                          is.schon.org
> Martin Bähr       http://www.iaeste.or.at/~mbaehr/
>


-- 
Axel

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to