Higher-Order Programming in C

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jonathan Bartlett

    #1

    Higher-Order Programming in C

    Just thought you all might be interested in an article I just finished
    about higher-order functions, and their use in Scheme and C:



    This is part of a series of articles I'm writing about functional
    programming and how it can be used to even in procedural languages.
    This even includes a section on object-oriented programming in C (not
    C++) and Scheme.

    Jon
    ----
    Learn to program using Linux assembly language

  • Eric Sosman

    #2
    Re: Higher-Order Programming in C



    Jonathan Bartlett wrote:[color=blue]
    > Just thought you all might be interested in an article I just finished
    > about higher-order functions, and their use in Scheme and C:
    >
    > http://www-128.ibm.com/developerwork...-highfunc.html
    >
    > This is part of a series of articles I'm writing about functional
    > programming and how it can be used to even in procedural languages.
    > This even includes a section on object-oriented programming in C (not
    > C++) and Scheme.[/color]

    Mostly, it reads like a Scheme advertisement -- "If
    you want Lisp, you know where to find it." The C code
    could do with some cleaning up; in particular, the manual
    imitation of a closure invokes undefined behavior. It is
    flat-out incorrect to invoke a function like

    int nextval(void *environment);

    via a function pointer described as

    typedef void * (*generic_funct ion)(void *, ...);

    without first converting the pointer to agree with the
    type of the called function. And no, this isn't some kind
    of "academic" concern, pertinent only to the DeathStation
    line: there are real computers on which this will fail.

    --
    Eric.Sosman@sun .com

    Comment

    • jacob navia

      #3
      Re: Higher-Order Programming in C

      Jonathan Bartlett wrote:[color=blue]
      > Just thought you all might be interested in an article I just finished
      > about higher-order functions, and their use in Scheme and C:
      >
      > http://www-128.ibm.com/developerwork...-highfunc.html
      >
      > This is part of a series of articles I'm writing about functional
      > programming and how it can be used to even in procedural languages. This
      > even includes a section on object-oriented programming in C (not C++)
      > and Scheme.
      >
      > Jon
      > ----
      > Learn to program using Linux assembly language
      > http://www.cafeshops.com/bartlettpublish.8640017[/color]

      Very interesting message.
      Thanks for the tip.

      jacob

      Comment

      • Rob Thorpe

        #4
        Re: Higher-Order Programming in C

        Jonathan Bartlett <johnnyb@eskimo .com> wrote in message news:<424c62b4$ 1@news.tulsacon nect.com>...[color=blue]
        > Just thought you all might be interested in an article I just finished
        > about higher-order functions, and their use in Scheme and C:
        >
        > http://www-128.ibm.com/developerwork...-highfunc.html
        >
        > This is part of a series of articles I'm writing about functional
        > programming and how it can be used to even in procedural languages.
        > This even includes a section on object-oriented programming in C (not
        > C++) and Scheme.
        >[/color]

        Very interesting. I would write many programs in Scheme if I could
        easily link them to outside libraries like I can with C.

        I think that there are slightly more safe/pleasant ways to do many of
        the things done in this article, but I can't remember them right now.
        I'll post them if I remember them.

        Comment

        • Jonathan Bartlett

          #5
          Re: Higher-Order Programming in C

          [color=blue]
          > Very interesting. I would write many programs in Scheme if I could
          > easily link them to outside libraries like I can with C.[/color]

          Many Scheme implementations allow this with little difficulty. Chicken
          can actually parse some C prototypes directly. Implementing glue code
          is pretty simple in most of them.

          Jon

          Comment

          Working...