Creating objects

You create objects by means of MQL statements.

OK. Which MQL statements do I use?

There are basically three you can use:

  • CREATE OBJECTS WITH OBJECT TYPE
  • CREATE OBJECT FROM MONADS
  • CREATE OBJECT FROM ID_DS

You should look them up in the MQL User's Guide for details.

What are the pros an cons of each?

  • Well, CREATE OBJECTS WITH OBJECT TYPE is for batch-loading, and is much faster if you create many objects than creating each object individually with a CREATE OBJECT statement. You should probably think about using this statement rather than one of the other two if at all possible. The downside is that you won't get the ID_Ds from the newly created objects back. If you need them, for example, for referencing from other objects, you should probably use one of the CREATE OBJECT statements, which do return the ID_D of the newly created object.

  • CREATE OBJECT FROM MONADS creates a single object, assigning the monads directly. Use this if you wish to create one object and know its monads. It is rather slow, but it returns the ID_D of the newly created object.

  • CREATE OBJECT FROM ID_DS creates a single object, assigning the monads from the monads of already-existing objects with specific ID_Ds that you supply. It is rather slow, but it returns the ID_D of the newly created object.

Can you give me some examples?

Sure

// Create a clause object spanning the 
// first four monads of the database.
CREATE OBJECT
FROM MONADS = {1-4}
[Clause]
GO


// Create the words of the clause "The door was blue."
CREATE OBJECTS 
WITH OBJECT TYPE [Word]
CREATE OBJECT
FROM MONADS = {1}
[
  surface := "The";
]
CREATE OBJECT
FROM MONADS = {2}
[
  surface := "door";
]
CREATE OBJECT
FROM MONADS = {3}
[
  surface := "was";
]
CREATE OBJECT
FROM MONADS = {4}
[
  surface := "blue.";
]
GO

Previous:Create on-the-fly
Up:Population
Next:How do I make a syntax tree?