Better HN
topnewbestaskshowjobs
Log inSign up

vmathew

7 karma · joined Jun 21, 2010 (16y ago) · 7 submissions

http://vmathew.in
Submissions

comment 15y ago · link · parent

It has FExpressions, the earliest form of macros. The arguments of an FEXPR is evaluated on demand. (http://nostoc.stanford.edu/jeff/llisp/19.html)

2.

#35 device review(youtube.com ↗)

2 points · by vmathew · 16y ago · discuss

comment 16y ago · link · parent

In the first place, a language that exposes pointers may not be able to do away with null. But as for languages like Java, the problem can be solved with the help of an implicit, non-mutable default object:

    Foo foo; // initialized to default
    if (x) {
       // stuff
       foo = Foo.p1;
    } else {
      // stuff
      foo = Foo.p2;
    }
    // No need to check if this is a valid reference, it always will be.
    foo.bar();

comment 16y ago · link · parent

    class Node {
        // May not be a real situation for a Node class,
        // but makes a point.
        Node getLeft() {
            return left;
        }
    }

    // No more checks against NULL. In fact code becomes simpler for
    // the user of the library.
    node.getLeft().getLeft().getValue();
I don't think the class definition is much too complicated, except for the declaration of the EMPTY field. What we need is a non-mutable, class-wide, default object, not null. We don't need to explicitly declare this object, if the language does that for us and make it accessible through a keyword - say 'default':

    if (n.left != default) {
         traverse(n.left);
    }

comment 16y ago · link · parent

This is one possible way of doing it:

    class Node {
        static const Node EMPTY_NODE = Node();
        String key;
        String value;
        Node left = EMPTY_NODE;
        Node right = EMPTY_NODE;

        Node(String key, String value) {
            this.key = key;
            this.value = value;
        }

        static void traverseInorder(Node n, Visitor v) {
            if (n.left != EMPTY_NODE) {
               traverseInorder(left, v);
            }
            v.visit (n);
            if (n.right != EMPTY_NODE) {
               traverseInorder(right, v);
            }
        }
    }

comment 16y ago · link · parent

A systems programming language that expose pointers will not be able to shed NULL. But a higher-level language can and a "pure" OOP language should - because null make objects unable to respond to messages. Something that claims to belong to the type system and cannot respond to messages just don't fit in there.

7.

Do we really need null?(home.vmathew.in ↗)

5 points · by vmathew · 16y ago · 10 comments