Note that this discussion addressees the language at a point in development. The current version has changes.
- Are labels only defined in the function they were defined in?
- What would happen if I tried including the source file?
cellsneeded to use a cell? The cat program seems to work fine without it.
funcneed any arguments?
- Are you able to create new cells past a bound?
Thanks for reaching out!
- Yes, labels are only defined within a function (this was not the case in macrobeep)
- I had not thought of that! It's a great test case. I'm currently using the same Linker from macrobeep 1.4 which gives ErrCode 0 and a StringIndexOutOfBoundsException; (this is certainly a linker error case).
- cells is for statically allocating cells to a function. Initially, all memory was allocated this way, but this made taking input of more than
one cell less than elegant. So I thought it was best to allocate memory dynamically instead. This provided a few advantages:
- with static allocation, all the cells need to be allocated first. If a programmer does not know how many cells they need, they have to compensate by adding a large number and wasting space.
- if a programmer needs to add cells, they can do so at any point in the function without overwriting cells in use.
- func needs one argument, an identifier, or name
- No, you cannot create cells past a bound. I created that instruction so that function memory could be limited to an explicit number of cells.
It's easier to show than tell. Here's a program using a summation function
func main sum &0 1 1 #cell 0 is 2 after this call sum &0 &0 &0 #cell 0 is 4 sum &0 &0 &0 #cell 0 is 8 out &0 #output an 8 return ## &loc is an address in the parent function (also, note that &&loc is an acceptable type in the return case) a and b are values, addends to sum. ## func sum &loc a b set &0 a add &0 b return &&loc &0
Functions, Types, and Errors
- Are function return and input types implied?
- Is it possible to make a function take a string/character?
- Or have a function that can only take 3 addresses?
- How would you make a function with optional arguments?
- How would you make a function that can take infinite arguments (the array instructions)?
- Can you use special characters in function names?
- Will there be try and catch instructions?
- Functions are not typed, however inputs and outputs can be typed. All arguments are assumed to be values unless specified to be an address.
func printTheThing ThingtoPrint pr ThingtoPrint return
func &a &b &c #statements return
- In terms of optional function arguments, I do plan to implement function overloading, but not default values, an unspecified argument cannot be set in the function arguments line.
- Currently there is a limited number of arguments allowed per line (64) to make debugging the interpreter easier, but that could change.
- Yes, but it's not a good practice in general
- I do not plan to implement trys and catches yet, in general, less is more, I'm culling all instructions that are not essential for version 1. That said, I do this error handling fits the language design goals well. There are exceptions (like the instruction for subtraction). Perhaps a specialized goto statement, and statments to start and end a block?
handle go to the label in any of the listed errors occurs in a handle block Args: LABEL, ERRCODE OR SET OF ERRCODES
hend ends the handle block above
But then there is the question of how to handle this case:
handle handle handle hend
Perhaps the top two handles would be ignored somehow?
Nested handle blocks would certainly be on a stack stored by the call. When an error is thrown. The call checks the handle stack to decide what to do next.
Functions, Types, and Errors (part 2)
- Will there be a way to check if a parameter is a specific type (like a general print function that can take a value or string)?
- If you named a parameter in a way that overwrites a function or label what would happen if you tried using it?
- Will it be possible to create a lambda function?
- What would the point of
handleis just a goto if one of the specified errors happens?
- Will there be a way to throw an error?
- What could I do if I wanted to overload a function and give the old function a different name? An example would be if I made a new
addfunction that worked for strings too and I needed to keep the original function.
- What if I wanted to make a constant?
- I'm not quite sure how that would be used. There are only three types (or four if higher order functions are implemented)
- All arguments for a function are substituted using String replacement method, so it depends, but it's a pretty safe thing to do.
- As of now, no. I'm focused on keeping the language simple and finishing 1.0
- handle begins a block of statements in which an error will be handled.
hendends that block
- No, a programmer can write a message with pr and halt the program so it isn’t essential.
- User defined functions are renamable. In the current implementation, the instruction is run, not the user defined function.
- In general, I take a "less is more" or "hands-off" approach to keep the language simple. A "const" instruction is warranted, but no modifiers.
- Test each command for expected and unexpected arguments.
- Test for error cases.
- Prove useability via the implementation of the Game of Life and a simple command-line game to play.
- Prove useability via the implementation of various program forms on the esolangs wiki, especially finite state machines that take input, display output, and demonstrate arithmetic capabilities.
Questions and Thoughts
- According to the current documentation a structure cannot contain the value 0 inside of it without giving an error if you try to reference it. This does not seem correct.
- How would you initialize a structure from within a structure? For example, with the binary tree example, how would you initialize
- The referencing syntax looks bad. It's fine when you have
&b(2)but not so much when there's
&b(2(&b2(1(7))(9))). I suggest to make it
&b(2)(&b2(1)(7))(9)as this looks much more readable.
- I believe there should be a way to jump to different locations through handle blocks when given errors. Maybe something like multiple handle blocks in a row?
- Isn't the "Example of Function Print" section outdated?
- What is the point of
doc? It seems like it prints it out when the function has an error which can likely be generated by the compiler/interpreter if needed.
- Is there a point to
returnis the only one used?
- Can there be a way to allow infinite function arguments (such as putting a bucket as the last argument)?
- How would you compare strings?
- Why does the label not have anything needed to refer to it? It feels off when everything else has something that you need to put at the beginning to refer to it.
- The math library should have more info.
- Is the two sentence section about files needed? It seems to just take up space.