From: "TN" <[EMAIL PROTECTED]>
1. You can pipe into and out of control constructs in the sh-ksh-bash
family, including for and while loops.  This can be convenient and
elegant, but not absolutely necessary logically.

You thought possible IO-constructs with this but it isn't very clear to me what it'd mean. I think that constructs would just return values because would it be too complicated if they inherit something from their user (or elsewhere?)? I really don't know at this moment - perhaps there's a clever way to do it.


How would it be possible to apply this to loops such that
only in certain contexts they would return a value and what would those
contexts be?

I think that loops maybe shouldn't be considered as filters although it would be possible to use them like it. I think there shouldn't be automatic return values always.


@array=while(...){
  ...
  retnext;   #shouldn't be added automatically here
}

That enables a
maximum degree of "recursivability" that can lead to impressive
solutions some areas,

This is exactly what i'm looking for! Now loops, if's etc make the code break every time - even when it's not neccessary.


Perhaps, for example, it would be useful to implement a tagging system
on all control constructs such that if they were tagged in a certain way
all of their output (if any) was returned using a commonly accessible
read-write communication channel analogous to STDIN and STDOUT for
sh-ksh-bash scripts.  An advantage of this would be to make it easier to
write perl programs that do more complex processing in a way that is
more natural, flowing and intuitive for people.

IO starts finally to make more sense if there was such a tagging system. As a student of two languages (engl & perl), it's a real pity that i can't fully follow Your text and text in those links You wrote but i'm optimistic i got the point.



This is real example from what i was doing yesterday: if($subs->anna_tilavuus($x+$lisax,$y+$lisay,$z) < 100){ $subs->paivita($x); $udat{x}=$lisax; $udat{y}=$lisay; }elsif($subs->anna_tilavuus($x,$y+$lisay,$z) < 100){ $udat{y}=$lisay; }

If using return values, this could be wrote as:
  ($udat{x},$udat{y})=
     if($subs->anna_tilavuus($x+$lisax,$y+$lisay,$z) < 100){
        $subs->paivita($x);
        retlast($lisax,$lisay)
     }elsif($subs->anna_tilavuus($x,$y+$lisay,$z) < 100){
        retlast(undef,$lisay);
     }
  ;

Already there's more common code in the lower example because inside if's there's no need to know the caller's (here: $udat{x},$udat{y}) name. I understood that by IO-system, it would be possible to use caller's values or the caller itself (maybe in same style like it was an object) inside the 'if' with just having a reference or something to it - and have even more common code in several cases?

ville jungman, 2 laureston crescent, tower, blarney, cork, ireland
tel. + 353 - 21 - 451 6847, http://www.kolumbus.fi/vilmak
usko Herraan Jeesukseen, niin sinä pelastut. (apt. 16:31)





From: "TN" <[EMAIL PROTECTED]>
To: "'Ville Jungman'" <[EMAIL PROTECTED]>
CC: <[EMAIL PROTECTED]>
Subject: RE: Should loops return a value?
Date: Sat, 27 Sep 2003 20:01:20 -0400

I've been thinking about this issue more generally.  Programming
language enhancement does not seem to be especially a beginner's topic.
But a beginner may not have biases that inhibit greater insight; and
such insight could also be well served by a sufficient conceptual basis
and historical knowledge - to ensure that something new and significant
is really introduced.  After all, programming experts have been mulling
over "new" developments for over 40 years!

Here are few considerations that your discussion stimulated in me.  They
lead to a question for possible enhancement of pearl that I pose at the
end:

1. You can pipe into and out of control constructs in the sh-ksh-bash
family, including for and while loops.  This can be convenient and
elegant, but not absolutely necessary logically.  It shows a sense in
which every control construct "returns" a value including loops.  In
this case that facility is based on a common underlying "medium" of
communication, namely the STDIN and STDOUT streams of chars.  This
"medium" can also be used to link scripts externally, a rudimentary but
powerful form of interprocess communication!  The basic idea has
appeared in several more elaborate forms of greater generality or for
certain application domains including:

A. The "communicating sequential processes" model and language (CSP) of
Tony Hoare.  CSP is a general model for concurrency and a widely and
well regarded useful way to achieve parallelism for non-trivial, real
world and often real time problems.  See http://www.usingcsp.com/.  CSP
has been instantiated in Java and has had active participation in
specialized conferences for 7 years.

B. The use of threads in programming, lightweight and otherwise, in an
effort to make complex systems development more efficient and affordable

/* The common "thread" in between (A), (B) and the discussion is that
CSP and thread programming provide a general mechanism for processes to
pass (and return) information to each other */

C. Image and signal processing and more generally data flow systems and
architectures that have many useful applications and instantiations and
tend to represent a higher level application of CSP concepts.  For
example, AVS/5, see (http://www.avs.com/software/soft_t/avs5.html)

2. Related new specific paradigms include cellular automata (see Stephen
Wolfram's work - http://www.wolframscience.com/) neural nets
(http://www-2.cs.cmu.edu/Groups/AI/html/faqs/ai/neural/faq.html) and the
mathematical theory of dynamical systems (see
http://www.artsci.wustl.edu/~philos/MindDict/dynamicsystems.html for a
definition of the latter).

3. At a more comprehensive biopsychosocial level, all of this fits with
post-postmodernism and evolution to and past the "yellow meme" in Spiral
Dynamics, see
http://www.spiraldynamics.com/reviews/SD/SDreview_Dinan.htm and the
writings of Ken Wilbur, for example
http://wilber.shambhala.com/html/books/kosmos/excerptD/part1.cfm/

4. Lisp as a special case of a programming language is unusually
congruent because all of its programs and the input and output they
accept have the same form, namely they are lists.  That enables a
maximum degree of "recursivability" that can lead to impressive
solutions some areas, for example mathematical theorem discovery and
proof in Lenat's AM program although it didn't conquer the world :), see
http://www.comp.glam.ac.uk/pages/staff/efurse/Abstracts/Why-did-AM-halt.
html

On another hand:

5. A time honored approach to problem understanding and solution has
been to decompose the problem space into a minimal spanning set of
orthogonal "vectors" (constructs, concepts).  In programming its been
found that only sequence, conditionality and iteration (looping)
constructs are needed for Turing completeness (see almost any college
level text on algorithms and data structures).  Often the language is
given certain implementation efficiencies through the use of an
underlying data structure, for example lists in LISP and stacks in
Forth, but in principle all Turing complete languages are logically
complete meaning any program in one can be translated into a program in
another.  Wolfram has demonstrated Turing equivalence even for a simple
cellular automata (ibid).  However, there are a lot of theoretical
issues around Turing equivalence, for example it has been proven that it
is not generally "decidable" ( see
http://www1.cs.columbia.edu/~galley/cs3261/outline.html).

And

6. While lumping together fundamental capabilities may have some human
or machine implementation efficiencies, particularly for certain types
of problems (or certain types of people), sometimes it has been
precisely the unlumping or decoupling of such capabilities that has lead
to breakthroughs, for example the separation of the existence and
visibility of variables that Nicklaus Wirth made in Modula-3 was a
critical precedent that logically led to object oriented programming as
we know it today!

7. Perhaps the single key characteristic that makes perl most resemble a
natural language is that the typing of variables is determined by
context.  That can be viewed as a method for relumping fundamental
capabilities in ways that are hopefully adequate and maybe even
interesting.  How would it be possible to apply this to loops such that
only in certain contexts they would return a value and what would those
contexts be?
Perhaps, for example, it would be useful to implement a tagging system
on all control constructs such that if they were tagged in a certain way
all of their output (if any) was returned using a commonly accessible
read-write communication channel analogous to STDIN and STDOUT for
sh-ksh-bash scripts.  An advantage of this would be to make it easier to
write perl programs that do more complex processing in a way that is
more natural, flowing and intuitive for people.

What do you think?

-tristram


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]


_________________________________________________________________




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to