Timeline for How do programming languages define functions?
Current License: CC BY-SA 3.0
19 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 1, 2020 at 17:10 | history | protected | gnat | ||
May 1, 2020 at 14:13 | answer | added | sameraze agvvl | timeline score: -1 | |
Sep 6, 2013 at 11:10 | vote | accept | Doorknob | ||
Sep 6, 2013 at 10:51 | comment | added | Doorknob | @nalply Hmm, interesting. I will definitely think about that. Thanks! | |
Sep 6, 2013 at 10:50 | comment | added | Doorknob | @ddyer Thanks! I googled for a lisp interpreter in different languages and that really helped. :) | |
Sep 6, 2013 at 10:48 | comment | added | nalply |
You could treat the functions as first class data, i. e., functions are things you work with inside your language. Using C as an implementation language, define a struct func_type where you store a pointer to the parsed representation of the function, for example an AST. Then it is possible to pass the function around inside your language. This is one of the solutions of the recursivity problem of the function representation. 'a' is an entry containing that struct. The AST contains an entry 'callSomething' of type func_type . Even functions calling themselves are possible.
|
|
Sep 6, 2013 at 6:16 | comment | added | ddyer | One concrete example is worth 1000 pages of explanation. You should get a tiny language implementation and study it. I recommend lisp or forth. | |
Sep 5, 2013 at 22:01 | comment | added | evilcandybag | If you are new to programming language design and implementation, you might want to check some of the literature on the subject. The most popular one is the "Dragon Book": en.wikipedia.org/wiki/…, but there are other, more concise texts that are also very good. For example, Implementing Programming Languages by Aarne Ranta can be obtained for free here: bit.ly/15CF6gC. | |
Sep 5, 2013 at 18:08 | vote | accept | Doorknob | ||
Sep 5, 2013 at 18:10 | |||||
Sep 5, 2013 at 18:00 | answer | added | KeithS | timeline score: 1 | |
Sep 5, 2013 at 15:15 | history | tweeted | twitter.com/#!/StackProgrammer/status/375638369151500288 | ||
Sep 5, 2013 at 13:22 | answer | added | Mason Wheeler | timeline score: 32 | |
Sep 5, 2013 at 13:19 | answer | added | Neil | timeline score: 4 | |
Sep 5, 2013 at 13:16 | answer | added | Thiago Silva | timeline score: 2 | |
Sep 5, 2013 at 13:15 | review | First posts | |||
Sep 5, 2013 at 13:17 | |||||
Sep 5, 2013 at 13:14 | comment | added | Doorknob | @SimonWhitehead I split the string into tokens, and then parse each token separately. | |
Sep 5, 2013 at 13:14 | comment | added | Simon Whitehead | In the past I have stored them all inline within my tokens and function calls are just jumps to a specific offset (much like labels in Assembly). Are you tokenizing the script? Or parsing strings each time? | |
Sep 5, 2013 at 12:59 | comment | added | Doorknob | Oh, and this is my first post on Programmers.SE, so please inform me if I'm doing anything wrong or this is off-topic. :) | |
Sep 5, 2013 at 12:57 | history | asked | Doorknob | CC BY-SA 3.0 |