Hacker News new | ask | show | jobs
by whitten 2267 days ago
Fe is a tiny language with only a few forms ie: if, while, do, define a variable, define a function, define a macro etc.. It uses an embedded parenthesis syntax similar to Lisp or Scheme, with prefix functions.

I couldn't see (other than reading the code) if you have an expression (foo bar quux) if foo is first evaluated before calling the result. I seem to recall Scheme follows this approach.

Alternately, the name foo could be looked up in a global symbol table and the result (presumably a lambda expression) is applied to the list of evaluated arguments (bar quux). I associate this approach with Lisp.

I didn't see any error trapping mentioned in the documentation, so I assume if you try to do something like divide by zero, that Fe will crash. How much work does it take to implement a simple error trap strategy ?

I didn't see if the language supports a fluid let (any variable name is looked up at run time when the reference is encountered thru the stack levels until the name is found. Presumably each time new variables are created with let, they would be added at run-time to the symbol table.

The other choice would be that the variables are lexically scoped. Thus when reading in the code, variables are "found" in the order the program is written on the page, and there is no searching of the run time stack frames to find the "innermost" version of the variable name.

From what I can see, Fe is a good language to use if you are happy with the capabilities the implementor defined initially. There is a set of functions, named after mathematical operators, like "+", "-", "*" etc. and logical operators like "AND" "NOT" etc. The doc says these functions take a variable number of arguments, evaluate them, and then the operator takes each of the results, and does some operation using them, such as adding them together, or returning false if any of them are false (AND)

I see nothing in the docs suggesting how a programmer would create his own functions that function in this way.

It's not clear if the logical operators "short cut" on evaluation of the arguments. ie: with (or bar quux qide) does the value of quux even get evaluated if bar is true ?

Is there a short and sweet checklist to help describe a programming language you have never seen so you know how these types of issues are addressed in the implementation?

Thanks for sharing your code. I always learn when I read other people's work.

1 comments

> I didn't see if the language supports a fluid let (any variable name is looked up at run time when the reference is encountered thru the stack levels until the name is found. [...]

These are called dynamic variables in Lisp. They're only really useful as a way of doing things like I/O redirection, and you can just shallow-bind them to make them fast (but then they need to be per-thread as well, and pushing a binding requires unwind-protect to pop on unwind).

> The other choice would be that the variables are lexically scoped. [...]

That's what the README says Fe does.

fluid-let is a famous Scheme imitation of dynamic variables.

SRFI-15: https://srfi.schemers.org/srfi-15/srfi-15.html [1999]

Ahh, ok.