User Tools

Site Tools


macros:types

This is an old revision of the document!


Types

All data - in particular properties and functions' parameters - need to be of a certain type. Essentially, this is a convention you know from everyday's life. There are some information which are always a number - e.g. the phone number. Then there are other information which are always words, e.g. a person's name.

Furthermore, there are some sub-types. E.g. a phone number will always follow a specific pattern (per country), a zip code - which in many countries is also a number - will follow another pattern. If you, by accident, dialed a person's zip code instead of their phone number, most likely you will get no connection (which at least gives you immediate fedback that something is wrong), but in rare cases you might even get connected. But most likely not to th person you intended to speak to. Hence, the most important lesson is: types matter. Passing the wrong type of a parameter to a function will lead to wrong results, and most likely to errors (in which case usually the macro does nothing).

And: there are more complex types as well. Imagine the data type 'address'. An address in real life comprises of a street name, a house number, a zip code, a city, and maybe a few more details. in general, such complex data types are refered to as objects or structures, and it is important to know the details of how they are composed.

Here, we only very briefly try to explain the various types you might come across when writing macros. Please feel free to refer to countless programming literature if you are interested in more details.

Casting - type conversion

As types are that important to adhere to, and as functions are very picky about what they want to get as input and what they maybe return, there are means to convert data from one type to another. This is called type casting. While this is a good thing in order to provide the correct data type, this invokes the next challenge: conversion rules. Some are easy to understand, e.g. casting an integer value to a float. Others aren't: what rule would you suggest to cast the string “Moving Light” into an integer value? But usually you shouldn't need to bother. Just use the appropriate casting function, e.g. in the example changexfade.

Datatypes in this Wiki

Here is a list of the types covered in this wiki:

You could leave a comment if you were logged in.
macros/types.1509294793.txt.gz · Last modified: 2017/10/29 16:33 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki