Most assemblers don't provide an indirect JSR instruction but it's easy to write a macro that serves that purpose. Where beforehand you've stashed PROGRAM in register RP. At address PROGRAM, you store the list of 64-bit function addresses. Each function ends with a standard RET instruction. Each name stands for the starting memory address of that function. Let's say you have a list of assembly language function names FOO, BAR, BAZ, etc. Forth is unique in that its interpreter can look (and perform) a lot like compiled code. Simplify down to a simpler structure, like vector, or dictionary/HashMap, if possible.įorth can be interpreted but it can also be compiled in at least two or three different ways. Start with the Lisp-lists as a prototypeĢ. With that power, comes great confusion 3 months later when you forget the structure.Ī good, professional programmer probably should:ġ. csv files) and working off of that.īut Lisp gives you that "power" to have a true hierarchy / language built into your lists. ini files by Python's ConfigParser, for example. There's something to be said about writing configuration as. They are probably "too generic" for a lot of applications, much like XML or JSON is overkill. Given how generic lisp-lists are, they're really free form and could be anything. I never wrote Lisp code professionally, mostly just as a hobby for myself. In a lot of Lisp code, people don't bother to use that feature, and instead do a lot of (undocumented (sets of ((lists) that ) have some unknown) undefined structure) That was fun as long as feeling smart about the fact that I could do it outweighed feeling annoyed at everyone else doing it, but in the end, the feeling of smartness faded and the feeling of annoyance remained. Of course in Lisp your code can and should have clearly named functions that encapsulate your use of conses to build data structures, but casually violating that encapsulation, or better yet doing without encapsulation at all, just playing with conses, was the cool way to do it, the way you programmed if you had even a little bit of swagger. It's much easier to read code that uses named data structures. YMMV since my adventures with Lisp were around twenty years ago, but reading code, you'd see somebody constructing a list with a bunch of nested lists inside it, or some other complicated structure with conses, and you'd have no idea what it was or how they intended to use it, and you'd just have to read the code until you figured it out. It was possible, and it was deemed to be elegant, so people went too far with it. I think building everything out of conses held Lisp back. Therefore, binary trees can represent any tree, and if allowed to loop, I'm sure the cons / binary tree node can be forced into working with graphs. Its the flexibility of this data-structure that is incredible.ĮX: the "left" child is "down a level", and the "right" child is "next sibling". Whether you wanna see them as binary trees, Lisp-lists, or graphs or even collections of malloc'd() nodes, it doesn't really matter. Knuth tries to explain the topic in his "binary trees representation of trees" subject, and notes that pointers to (two pointers) elegantly solves a wide variety of problems. Choosing a data-structure too early can hamper your understanding and bias you towards a possibly inefficient solution. Getting a basic implementation of whatever project you're doing in cars-and-cdrs in (cons) is more important anyway for learning about your problem. On top of that, Lisp has all kinds of shortcuts to make list processing easier to type. Maybe not as fast as a properly designed specific data-structure, but it will work. List processing itself is an elegant technique: a garbage collector tuned for exactly (cons) (2-element "items" that have a car-and-cdr, and the cdr is usually a pointer to another cons), is small, simple, elegant to implement, and works for almost any problem imaginable. For most code, you don't really care about runtime, and you really just need "a data structure that probably can solve the problem", and the (cons) based list of car and cdr solves it. I jest a little bit, but that's really the fundamental thing about list-processing. The real elegance of Lisp is that malloc() has been renamed to (cons) and everyone feels smarter about it.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |