Thread View: comp.lang.logo
5 messages
5 total messages
Started by Ocie *crow* Mitchell
Fri, 09 Oct 1992 06:57
um, maybe this is a silly question
Author: Ocie *crow* Mitchell
Date: Fri, 09 Oct 1992 06:57
Date: Fri, 09 Oct 1992 06:57
15 lines
1198 bytes
1198 bytes
I was playing around with logo and I was wondering, how do you set the value/type of a variable? [BASIC] x=10 [C] int x=10 [Logo] ?... ----------------------------------------------+------------------------------- ``What do you think sirs?'' -Joel (mst3k) | do not write above this line ----------------------------------------------+------------------------------- __ _ _ _ | Ocie Mitchell / ') ' ) ) ) _/_ / /) /) | omitchel@jarthur.claremont.edu / / _. o _ / / / o / _. /_ _ // // | Q:is that your real name? (__/ (__(_(<_ / ' (_(_(__(__/ /_(<_(/_(/_ | A:yes, it is my real name. ----------------------------------------------+-------------------------------
Re: um, maybe this is a silly question
Author: dale.e.parson
Date: Fri, 09 Oct 1992 12:36
Date: Fri, 09 Oct 1992 12:36
10 lines
718 bytes
718 bytes
In article <1992Oct9.065708.25074@muddcs.claremont.edu> omitchel@jarthur.claremont.edu (Ocie *crow* Mitchell) writes: >I was playing around with logo and I was wondering, how do you set the >value/type of a variable? > >[BASIC] x=10 >[C] int x=10 >[Logo] ?... > make "x 10
Re: um, maybe this is a silly question
Author: Brian Harvey
Date: Fri, 09 Oct 1992 14:20
Date: Fri, 09 Oct 1992 14:20
46 lines
2178 bytes
2178 bytes
The answer
make "x 12
is correct but really only answers part of the question.
In languages like BASIC and C, there is a heavy emphasis on the style of
programming in which instructions are executed in sequence, and most of
those instructions change the values of variables. (In BASIC this is
because the language is not capable of any alternative; in C, it's because
the can't-teach-an-old-dog programmers aren't.)
In Logo it's not very common to use MAKE at all, or to change the value
of a variable in any other way. Instead, Logo emphasizes functional
programming, in which the computation progresses when a function calls
another function. (The function can call itself; that's recursion, which
Logo uses instead of conventional looping structures like WHILE.)
Example: Euclid's GCD algorithm, both ways:
------------------------------ C ------------------------------
int gcd(int a, int b)
{
while (b != 0) {
int temp = b;
b = a % b;
a = temp;
}
return a;
}
------------------------------ Logo ------------------------------
to gcd :a :b
if :b = 0 [output :a]
output gcd :b (remainder :a :b)
end
======================================================================
The point to notice is the complete absence of assignment instructions
in the Logo (recursive) version. (Also, along with that, there's no
need for the extra variable temp.) It would be possible to write it
the same way in C, but most C programmers wouldn't.
I hope I'm not insulting you by telling you things you knew already;
the original message didn't make that clear.
Re: um, maybe this is a silly question
Author: Isaac Rabinovitch
Date: Sun, 11 Oct 1992 19:21
Date: Sun, 11 Oct 1992 19:21
44 lines
2448 bytes
2448 bytes
Hey Ocie, that wasn't such a silly question after all!
In <1b44g5INNqq1@agate.berkeley.edu> bh@anarres.CS.Berkeley.EDU (Brian Harvey) writes:
>The answer
> make "x 12
>is correct but really only answers part of the question.
>In languages like BASIC and C, there is a heavy emphasis on the style of
>programming in which instructions are executed in sequence, and most of
>those instructions change the values of variables. (In BASIC this is
>because the language is not capable of any alternative; in C, it's because
>the can't-teach-an-old-dog programmers aren't.)
>In Logo it's not very common to use MAKE at all, or to change the value
>of a variable in any other way. Instead, Logo emphasizes functional
>programming, in which the computation progresses when a function calls
>another function. (The function can call itself; that's recursion, which
>Logo uses instead of conventional looping structures like WHILE.)
>Example: Euclid's GCD algorithm, both ways:
>.....
This raises two questions: First, Why does your book (*Computer Science
Logo Style*) spend so much time on make and on "instruction sequence"
programs? Second, how do you justify the abolition of assignment and
iteration to someone who is used to using them? I don't mean the
fancy doctrines about denotational elegance and all that. Few
programmers are interested in that stuff, assuming they can understand
it. What are the *practical* advantages?
Incidentally, you probably should make it clear that you're talking
about a specific kind of recursion, namely tail recursion. Most C
programmers will look at your Euclid's example, scratch their heads,
and say, "Gee, that's OK if you can set aside a meg for the stack.
These list guys sure don't know how to program in the real world...."
--
ergo@netcom.com Isaac Rabinovitch
{apple,amdahl,claris}!netcom!ergo Santa Cruz, CA
You will be assimilated. Resistance is futile.
Re: um, maybe this is a silly question
Author: Stan Webb
Date: Mon, 12 Oct 1992 15:55
Date: Mon, 12 Oct 1992 15:55
18 lines
1215 bytes
1215 bytes
In article <1b44g5INNqq1@agate.berkeley.edu>, bh@anarres.CS.Berkeley.EDU (Brian Harvey) writes: > The answer > make "x 12 > is correct but really only answers part of the question. > [ nice exposition on functional versus procedural programming deleted...] BUT... As one of those maligned C programmers (actually, I use C++ almost all the time these days - hey, maybe he's not talking about me after all... :-), I'm bothered by the casualness with which most FP people ignore the notion of "state". Oh well, never mind. This discussion doesn't really belong here anyway. Stan
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads