Talk:Forte

From Esolang
Jump to navigation Jump to search

There is an inconsistency in the article: It states that behavior is undefined if a command is renumbered while running, but the example seems to depend on it. I think the example should be right because otherwise making loops becomes much more awkward. --Ørjan 19:03, 27 Feb 2007 (UTC)

The bug was in the example, not the spec. Making loops doesn't become substantially more awkward; I've corrected the example as a result of your comment above. ais523 10:32, 28 Feb 2007 (UTC)

Quine

The quine is neat, but seems to depend on command lines not being ended by newlines in strings, which the spec doesn't say anything about, but which I suspect wasn't consciously intended to be allowed, given FORTE's old-style BASIC roots. --Ørjan (talk) 06:59, 27 January 2017 (UTC)

If anyone's interested, here's a quine I made in 2014: http://yiap.nfshost.com/esoteric/forte/kquine.fo --Keymaker (talk) 12:36, 28 January 2017 (UTC)
The quine almost certainly comes from PPCG (one of the few places which makes heavy use of esolangs, other than us), and they define languages to be defined by their interpreter, without caring about specifications. For example programs here, we should probably stick to ones that actually comply with all readings of the specification, in case of future interpreter updates. --ais523 12:42, 28 January 2017 (UTC)

The first error

I don't see why it would be an error. It should go like this:

   > 10 LET 10 = 11
   15 PRINT 10
   20 END

10 is set to 11. We will show this by replacing all tens with elevens.

   > 11 LET 11 = 11
   15 PRINT 11
   20 END

11 is set to itself. I'll cover this later. For now, this'll be a nop.

   11 LET 11 = 11
   > 15 PRINT 11
   20 END

11 is printed. 11 is still 11, so it just prints 11.

  11 LET 11 = 11
  15 PRINT 11
  > 20 END

The program ends.

Now, what about 11 = 11? What if you think about it as a goto on the number line?

Well, why not put that as the error instead? LET 200 = 201 is only just a cause.

From the spec: "If a command's line number is redefined while the command is executing, even indirectly, this leads to undefined behaviour". So it's an error because it's defined to be an error.
The reason I defined it to be an error is because I found it inelegant for lines to move themselves around, rather than to be moved by other lines; in particular, there's more than one sensible interpretation of what should happen to the instruction pointer, and I wanted it to be more or less obvious just by looking at it how a Forte program would work. --ais523 21:33, 10 April 2020 (UTC)

Reassignable variables

One major caveat in this language is that the left-hand side of an assignment is also an expression. Doing LET 5 = 19 and then LET 5 = 25 not only assigns 5 to 25, but also assigns 19 to 25. This makes it tricky to have the equivalent of mutable variables without leaving a trail of numerical destruction.

I've actually figured out a way to do this, however:

  • Divide the number system into what it is modulo 10.
  • Reserve all integers below a certain point (1000 is good, but you could use anything).
  • Take one digit and use it for a stream of values to contain the necessary "trail of numerical destruction" (I'll use 2 for this example.)
  • Take another digit and use it for the actual variable (I'll use 1.)
  • To set a value, use LET 1002 = 1002 + 10 : LET 1002 - 1 = (value) (If you have multiple trails, replace 10 with the number of trails multiplied by 10 so that each trail still gets unique links.)
    • This redefines 1002 to the next number in the trail, but if 1002 is already defined, it will also redefine further trail elements. In the end, 1002 will always refer to the end of the trail. Subtracting 1 from it gets a unique number to reassign. If the trail is at its third element, 1002 will mean 1032, and 1002 - 1 will mean 1031. Redefining 1002 again will make it mean 1042, and 1002 - 1 is now 1041.
  • To access the value, simply use (1002 - 1). This will always refer to the link at the end of the chain.
  • Note that most ones-place digits are still left alone, so you can use them for looping.

Also, if you want to have unbounded values, instead of reserving all numbers below a certain point, you can reserve all multiples of 10. To use this, every number used as a value will have a zero after it, multiplying will have to be followed by a division by 10, and in other cases division will have to be defined in terms of other operations. BoundedBeans (talk) 04:29, 15 December 2022 (UTC)