rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
* builtins and more
@ 1993-09-22 12:52 malte
  1993-09-22 16:57 ` Chris Siebenmann
  0 siblings, 1 reply; 3+ messages in thread
From: malte @ 1993-09-22 12:52 UTC (permalink / raw)
  To: rc

If simplicity is often the same as useability, then let me remind you
of the shift operator. Can there be a cleaner concept than the existing
of list and variables ? And isn't * just another variable except for the
property of being initialized at function invocation ? So how comes that
shift cannot shift variables other than * ? Probably because in sh variables
aren't lists. I find it much harder to remember to include some file to
overload the shift functionality. Not talking about the additional security
checking involved if a script may be executed by root. So consequently
simplicity means enhancing the shift operators functionality. And even if
you think this is false, have you ever thought about
    "x = ( 1 2 3 ) echo $x(0)" ?
Why is $*(0) a special case ? Wouldn't it be cleaner to have another special
variable for that ? And what about omitting shift ? Here's the sceleton of
a function as a replacement for shift:

fn shift {
    switch( $#* ){
        case 0; echo cannot $0 >[1=2];
                return 1;
        case 1; return 0;
        case *; n = ( 1 1 ){
                    while(){
                        echo $*($#n);
                        if( ~ $#n $#* ) {
                            break;
                        } else {
                            n = ( $n 1 )
                        }
                    }
                }
                return 0
    }
}
Instead of "shift" you'll have to type * = `{ shift $* }


So, having raised all these questions: I think there is a very close connection
between datastructures and algorithms on them. With the fundamental data-
structure being lists, I miss the necessary operators (operations).

About the performance of a backquote-style read:
I have checked the difference between
    while(){ echo `{ /bin/echo true }}
and
    while(){ echo `{ echo true }}
on my favourite machine. It seems to me that the exec(2) is by far more
expensive than the fork(2). So the backquote solution may be a good compromise
between clearity and performance.

Btw, I dimly remember Byron asked for a rc wish list sometime around Xmas.
Wasn't this meant to be a request for possible improvements ? I mean, even
changes to rc syntax and semantics ?

Malte


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: builtins and more
  1993-09-22 12:52 builtins and more malte
@ 1993-09-22 16:57 ` Chris Siebenmann
  0 siblings, 0 replies; 3+ messages in thread
From: Chris Siebenmann @ 1993-09-22 16:57 UTC (permalink / raw)
  To: rc

 A shift operator that has to be used as 'x=`{shift $foo}' is a bad
shift operator; it can't be applied to arbitrary lists. Consider a
list with an element that has a space in it, or a newline.

	- cks


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: builtins and more
@ 1993-09-22 16:49 Alan Watson
  0 siblings, 0 replies; 3+ messages in thread
From: Alan Watson @ 1993-09-22 16:49 UTC (permalink / raw)
  To: rc

Malte writes:
> About the performance of a backquote-style read:
> I have checked the difference between
>     while(){ echo `{ /bin/echo true }}
> and
>     while(){ echo `{ echo true }}
> on my favourite machine. It seems to me that the exec(2) is by far more
> expensive than the fork(2). So the backquote solution may be a good compromise
> between clearity and performance.

On DEC MIPS and Alpha machines, fork and exec are both take
approximately the same time.  Read is a perfomance hack, and a worse
one than builtin echo; it isn't as elegant as `line, but it is fast
enough to be much more useful.  I would much rather see fork and exec
speeded up by a few orders of magnitude, but we all know that isn't
going to happen.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1993-09-22 16:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1993-09-22 12:52 builtins and more malte
1993-09-22 16:57 ` Chris Siebenmann
1993-09-22 16:49 Alan Watson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).