AgendaItem.isReady is a what?

advlite3 questions. What exactly is AgendaItem.isReady? This is more of a classic programming language question (what type is it?). In actor.t I’ve seen 3 different things:

isReady = true
isReady = (libGlobal.totalTurns >= readyTime && inherited())
isReady()
{
...
}

So, is it a literal or a function? Is the 2nd statement (predicate) evaluated every turn or only once at construction? The manual mentions that isReady can be a “declarative” statement, but I’m not sure what that means.

Any clarification is appreciated!
-Brad

This is really a question about the TADS 3 programming language rather than anything specific to adv3Lite.

In TADS 3, if you have an object property it can be defined either as a constant, or an expression, or as a method, so the following are all legal property definitions:

foo = 2

foo = 1 + 1

foo() { return  1 + 1; }

And they can all be used more or less interchangeably, as convenient.

So, AgendaItem.isReady can be a constant (true or nil or anything else - anything other than 0 or nil is regarded as effectively true) or a method that returns a value or an expression (which is effectively a syntactic shortcut for a method).

TADS 3 is dynamically typed, so properties and variables don’t have fixed types, they simply take on the type of whatever value is assigned to them. (It is, however, strongly typed in the sense that it will complain if you try to do operations on the wrong type, such as testing if(x > y) when x is an integer and y is a string).

A declarative statement is one in which an initial value is assigned to a property in an object definition, e.g.

myAgenda: AgendaItem
   isReady = true
;

As opposed to subsequently assigning a value in an executable statement, e.g.

[code]
myAgenda: AgendaItem
isReady = nil // declarative

makeReady(stat)
{
isReady = stat; //executable
}
;[/code]

But perhaps you need to study the TADS 3 System Manual which sets out an explains the TADS 3 language in detail.

isReady = (libGlobal.totalTurns >= readyTime && inherited())

It’s evaluated every time isReady appears in an expression in a statement that’s being executed elsewhere, i.e. whenever some other part of the program needs to know the value of isReady. It’s equivalent to writing:

isReady()
{
  return libGlobal.totalTurns >= readyTime && inherited();
}

Thanks Eric!

It was the parenthesis-syntax for defining a method that I had missed. Makes perfect sense.

-Brad