Talk:Libertas

From Esolang
Jump to navigation Jump to search

Runtime Errors

Runtime-error free? What would it do in these situations?

  • Runs out of memory.
  • Multiplies two strings.
  • Reads from a closed or nonexistent file.
  • Divides by zero.
  • Uses the value from something that has not been defined (including, say, method calls on nonexistent objects).
  • Passes the wrong number of arguments to a function.

This is just some possibilities for runtime errors of the top off my head and by skimming the list of Python exceptions. If you can actually figure out something logical other than raise an error or fail that the language can do in these situations (and any others anyone can think up), you may actually have a runtime-error free language. —Maharba 19:41, 11 November 2011 (UTC)

Well, you can handle all of those; the first one could just return a null object or similar. I don't see any evidence that these have been considered for Libertas, though, and this article has little worth as just a list of examples, as opposed to an actual specification. Unless we get more information on it, I think it should be in the joke languages category. —ehird 22:20, 11 November 2011 (UTC)

Good questions, I am actually planning to solve them all in the implementation:

- Runs out of memory: Never happens, it will destroy ANY MEMORY AVAILABLE TO MAKE ROOM for the new object

- Multiplies two strings: performs char-level ascii multiplication

- Reads from a closed or nonexistent file: returns empty strings / records

- Divides by zero: Stores an "infinite/undefined" value in the variable

- Uses the value from something that has not been defined (including, say, method calls on nonexistent objects): it will depends on situation

- Passes the wrong number of arguments to a function: The extra ones are ignored, the missing one are defaulted to 0/null/"" depending on the case

Pegasus 23:09, 11 November 2011 (UTC)

Alright, what if you try to create a single object so large it would take more memory than the computer has? If variables can have an "undefined" value, what happens if you try to loop that many times or concatenate a string that many times? Also, here are some situations for using the value from something that has not been defined (I'm using python syntax because I don't know Libertas syntax):
  • x = someobject.somemethod(somevariable) # where neither someobject or somevariable are defined
  • x = someobject.somemethod(somevariable) # where someobject has no method somemethod
  • x += somevariable # where somevariable is not defined
  • x += somevariable # where x is not defined

Maharba 18:57, 12 November 2011 (UTC)

The program will simply return the maximum memory that was possible for the Libertas interpreter to access. Any access beyond the limits of the maxixum of the interpreter will return 0/""/null.
Undefined value is 0, So the loop would be just skipped, same with concatenation, it would return an empty string.
  • x = someobject.somemethod(somevariable) # X value is a reference to somemethod. The someobject object is created an object with a single attribute (somemethod), and somemethod is another object with a single attribute: somevariable
  • x = someobject.somemethod(somevariable) # somemethod becomes a property of someobject, which only property is somevariable. the value of X is a reference to somemethod
  • x += somevariable # they all default to ZERO
  • x += somevariable # they all default to ZEROPegasus 19:27, 13 November 2011 (UTC)

Objects

It appears from the examples that the syntax

objectName value

creates an object and stores in it the given value. How is this value accessed? It appears from later examples that multiple values can be passes in the creation. How can they be distiniguished for access? How does one specify the type of an object when creating it? If (as it appears) an identifier in the list of values assigned to an object creates a named attribute of the object, how is this distinguished from getting the value of a variable? —Maharba 18:57, 12 November 2011 (UTC)

It does create named attributes, but it does not give them a value, only the default ones. In your example, objectName will receive a new property named value, that would be accessed using objectName.value, or even assigned with something like objectname.value = "hello world", but cant be assigned directly using the objectName value syntax.
Now, if the value is a constant, like would a string objectName "value", then it simply stores the "value" value inside of the object, as an inner, anonymous private member.
Note that I am in the middle of the implementation and A LOT of things would and will change Pegasus 19:07, 13 November 2011 (UTC)