Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion FORTH Trouble--Please Show Me
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Paul Rubin  
View profile  
 More options Oct 21 2012, 3:52 pm
Newsgroups: comp.lang.forth
From: Paul Rubin <no.em...@nospam.invalid>
Date: Sun, 21 Oct 2012 12:51:54 -0700
Local: Sun, Oct 21 2012 3:51 pm
Subject: Re: FORTH Trouble--Please Show Me

"Rod Pemberton" <do_not_h...@notemailnotz.cnm> writes:
> C has structs and arrays.  That's what's needed.

Well, C doesn't really have arrays ;-).

> "Closures" seems to be the one "magic" feature that everyone seems to think
> is missing from their favorite language.  What's so special about closures?

They're not magic.  You can do similar things with OOP or structs
containing function pointers and data, but closures avoid a lot of
syntactic clutter and bureaucracy compared to that.  Example in Python:

    def square(x):
      return x*x

    def derivative(f, h):  # approximate numerical derivative
      def df(x):
        return (f(x+h) - f(x)) / h
      return df

    print square(3)  # prints 9
    print derivative(square,0.0001)(3)   # prints approximately 6

You could write something like "derivative" in C with function pointers,
but it would be much messier.

> C has been used to implement nearly all, if not all, of the languages on
> Wikipedia's "closure" page that have closures or closure like structures.  I
> know I've been over _this_ previously on c.l.f. ...

It's just the usual situation of using a simpler tool to implement a
more advanced one.  Jet engines are made using screwdrivers, not the
other way around.  C is the screwdriver in that picture.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.