LtU Forum

What is a state?

Here are two versions of the factorial function written in Lisp (MuLisp).
A recursive version:

(DEFUN FACTORIAL (N)
((ZEROP N) 1)
(* N (FACTORIAL (SUB1 N))) )

and an imperative version,

(DEFUN FACTORIAL (N M)
(SETQ M 1)
(LOOP
((ZEROP N) M)
(SETQ M (* N M))
(SETQ N (SUB1 N)) ) )

The imperative version has two mutable states N and M. The way I look at it, the recursive version has a mutable state N. Is there any argument for saying that the recursive version has no state, or no mutable state?

Fogotten Book Title

For a "concepts of programming languages" class back in school I found a book in the library that helped very nicely--but I've since forgotten the title and author! It had a pelican J.J. Audubon-style on the cover, and had, I believe, "semantics" in the title. The author was, I believe, from Iowa St. Anyone know what book this is?

Duck Typing advocated where?

I used to think, (way, way, back), that Duck Typing was for dynamically typed languages. Involvement in developing the wikipedia page showed my naïveté, but I am left thinking "is duck typing advocated in languages other than the dynamic ones"?

I know that Boo has the specific duck as a type so thats one, any others?

An Accidental Simula User, Luca Cardelli

An Accidental Simula User (pdf slides) (abstract)

How o-o snuck behind a functional programmer and hit him in the head.

Newspeak, an experimental language in the style of Smalltalk

Languages that support both inheritance and nesting of declarations define method lookup to first climb up the inheritance hierarchy and then recurse up the lexical hierarchy. We discuss weaknesses of this approach, present alternatives, and illustrate a preferred semantics as implemented in Newspeak, a new language in the Smalltalk [GR83] family.
Gilad Bracha, On the Interaction of Method Lookup and Scope with Inheritance and Nesting (pdf)

... a standard example - a class representing points in the plane
Object Initialization and Construction Revisited

Declarative Assembler

Declarative Assembler. Christopher Kumar Anand, Jacques Carette, Wolfram Kahl, Cale Gibbard, Ryan Lortie. SQRL Technical Report #20, 2004.

As part of a larger project, we have built a declarative assembly language. This language enables us to specify multiple code paths to compute particular quantities, giving the instruction scheduler more flexibility in balancing execution resources for superscalar execution. The instruction scheduler is also innovative in that it includes aggressive pipelining, and exhaustive (but lazy) search for optimal instruction schedules. We present some examples where our approach has produced very promising results.

I think this paper is a nice followup to the recent discussion of SPE because it goes further than that paper by analyzing what data are necessary to achieve the ultimate goal of optimal or near-optimal instruction scheduling on superscalar architectures. In other words, it strongly suggests that we can do better than simply embedding low-level instructions in a high-level language by instead embedding a graph of desired results (vertices) and instructions for reaching them (edges) which can be analyzed to exploit cache-coherency, pipelining tricks, instruction-level parallelism, etc, or which could be supplied to an external scheduling algorithm based on some entirely different paradigm.

Thread-safe Singleton in C#

This has two parts. Please read first part first and think and then read second part.
+ First part:
Is this a thread-safe singleton class:

    1 public class SingletonClass

    2 {

    3     private SingletonClass () { Constructor (); }

    4     static SingletonClass instance;

    5     public static SingletonClass Instance

    6     {

    7         get

    8         {

    9             lock (typeof (SingletonClass))

   10             {

   11                 if (instance == null)

   12                     instance = new SingletonClass ();

   13                 lock (instance)

   14                 {

   15                     return instance;

   16                 }

   17             }

   18         }

   19     }

   20     void Constructor () { }

   21 }

--------------------------------------------------------------------------------

+ Second part:
I think this one is a thread-safe singleton:

    1 public class SingletonClass

    2 {

    3     public static object Hey_IAmStillUsingThisInstance_Lock = new object ();

    4     private SingletonClass () { Constructor (); }

    5     static SingletonClass instance;

    6     public static SingletonClass Instance

    7     {

    8         get

    9         {

   10             lock (typeof (SingletonClass))

   11             {

   12                 if (instance == null)

   13                     instance = new SingletonClass ();

   14                 lock (instance)

   15                 {

   16                     return instance;

   17                 }

   18             }

   19         }

   20     }

   21     void Constructor () { }

   22     public void DoSomthing () { }

   23 }

Which should be used this way:

  100 static void Main(string[] args)

  101 {

  102     lock (SingletonClass.Hey_IAmStillUsingThisInstance_Lock)

  103     {

  104         SingletonClass.Instance.DoSomthing ();

  105     }

  106 }

As you see it is a very very in-the-way kind of mistake! I did not beleive it when I came across it first time! The first one is thread safe just at the moment it's refrence is accessed by 'Instance' property not after that.
This filth is shared memory.
>:(

Nu - new LISP like language atop of Objective-C

At the recent C4[1] conference, Tim Burks announced a new language he designed, called Nu.

He says the following about it:

Nu is a new programming language that binds the expressive power of Lisp to the pervasiveness and machine-level efficiency of C by building on the power and flexibility of Objective-C.

...

Nu is object-oriented and functional. It is written in Lisp-like S-expressions but conforms to no preexisting Lisp standard.

Tim says that he started out from an effort to bridge Ruby to Objective-C, but the myriad of impedance mismatches led him to develop a new language that he can use instead of Ruby atop of Objective-C:

Instead of grafting two mature and overlapping language implementations together, I wrote Nu on, with, and for Objective-C. Instead of being problems to be bridged, the rich set of Objective-C classes became the building blocks of Nu.

Earlier in the introduction he says:

As a result, Nu has deep access to its own implementation. That gives its users an unusual ability to explore and understand Nu. Where there is understanding, there are few surprises.

A question on free variable capture.

I've been studying the lambda calculus by reading the available texts found doing your basic google search. A question has come up that I have not found a sufficient answer to.

When doing variable substitution in an application ((E1 E2)) it is fairly straight forward if E2 is a variable. When E2 is something more complex, like an abstraction, how do things work with regards to alpha conversion?

Do you first find all the free variables in E2, then rename those that exist free in E1? Or since E2 isn't a variable do not do an alpha conversion stage?

Anyone out there too familiar with lambda calculus, I'd appreciate a little assist.

-Chris

Tools for (PhD) Researching

(Sorry that this is a bit off-topic...)

I'm not talking about programming tools. Instead, I need something to organize my research progress. I learnt the hard way while I was doing my Masters that when I didn't keep track of my ideas and progress on a day-to-day basis, the task of thesis-writing became almost undoable at a later stage. That convinces me I need some "tool" to build the core of my thesis on a day-to-day basis.

I can be on a very wrong track, but what I currently have in mind is a personal wiki (e.g. based on Mediawiki) which allows me to have rich cross-referencing of ideas. Come to think about it, i think what i need are:

- a place to keep a journal
- a place to keep track of all the bios and allow me to add annotations/comments/thoughts
- something allows me to keep track of branches of new ideas and backtracking.

Any suggestions?

XML feed