ArticleslgStudy

science

SenseTalk

SenseTalk is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand SenseTalk rather than just read about it. In short: SenseTalk is a high-level English-like scripting language in the XTalk family, that supports both procedural and object-oriented paradigms. SenseTalk scripts are intended to be largely readable by ordinary people, including those with little to no training in programming.

SenseTalk — main illustration
SenseTalk — illustration

Key takeaways

  • SenseTalk belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect SenseTalk to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of SenseTalk from memory before moving on to harder problems.

Reference excerpt

SenseTalk is a high-level English-like scripting language in the XTalk family, that supports both procedural and object-oriented paradigms. SenseTalk scripts are intended to be largely readable by ordinary people, including those with little to no training in programming. To this end, SenseTalk includes a number of language elements that provide functionality oriented towards human tasks rather than the underlying machine behavior. For example, to check whether a quantity is divisible by 3, the script could use the expression if quantity is divisible by 3 … or if quantity is a multiple of 3 …, with the emphasis being on readability and a focus on the human concept of divisibility. Compare this to more traditional programming languages (C, Java, Python, etc.) where the same test would typically be written as if (quantity % 3) == 0 …, with the focus being on the machine operations needed to determine the result. This shift in focus away from the underlying machine computation, towards an English-like description of the behavior in human terms leads to the description of SenseTalk as a "people-oriented programming language".

Distinctive characteristics As a self-styled "people-oriented programming language", certain aspects of SenseTalk's design distinguish it from other programming languages, and give it a distinctive flavor. These range from mundane characteristics such as case insensitivity, to syntactic elements that enhance readability, to more subtle characteristics such as fluid variable types, to advanced features like units and the SenseTalk Pattern Language.

Case-insensitive SenseTalk keywords and variable names are all case-insensitive. This allows people to be casual in their use of capitalization without any change of behavior.

This is also true of the names of properties in a property list (SenseTalk's name for a dictionary or hash table).

In addition, text operations, including comparisons, searches, and so forth, are case-insensitive by default, although they can be made case-sensitive when needed.

Fluid types In addition to having case-insensitive names, variables in SenseTalk are unusual in some other respects. Variables don't need to be declared, and are typeless. A variable comes into existence when it is first used, and its type depends on the type of value that is stored in it. This flexibility goes beyond the "duck typing" found in other languages, in which a given variable has a type which is established when a value is assigned to the variable. In SenseTalk, a variable is considered a "container" that may contain any type of value. The type of value a variable contains can change during a script run, so the same variable may start off containing a number, then later a string, and then a list of values. This "type fluidity" allows people to work in a very flexible way, manipulating values at will, and treating each value according to how it is being used at a given point in the script. One consequence of SenseTalk's typeless variables is that, in general, there are no operator overloading — that is, operators which perform different operations depending on the type of variable they are working with. For example, in some languages, the + operator will perform addition when it is used with numeric operands, and will perform string concatenation when it is used with string operands. In SenseTalk, operands are all fluid, so it is necessary to have one operator to perform addition (+, which will treat its operands as numbers), and another operator for string concatenation (&, which will treat its operands as strings).

In this example, the + operator has higher priority than the & operator, so the expression is equivalent to '(1 + 2) & (3 + 4)' or '3 & 7' giving "37". If parentheses were used to perform the & operator first, then '1 + (2 & 3) + 4' would become 1 + "23" + 4 giving a result of 28.

Predefined variables SenseTalk includes hundreds of "predefined variables". These are variable names which can be used as ordinary variables, but which start off with a predefined value if they are used without first storing a value into them. Some of the predefined values are numbers, such as pi or zero. Many are special characters or symbols, such as euroSign, copyrightSign or hotBeverage. And a few have other types of values, such as jsonListFormat, which is a property list containing several key/value pairs that can be used for setting the listFormat global property.

Any variable that doesn't have a predefined value, and hasn't yet been explicitly assigned a value, will evaluate either as its own name or as empty depending on the context where it is used. This allows words to be used unquoted in many cases where quotes would otherwise be required.

Units SenseTalk includes full support for many different types of units (length, mass, time duration, volume, frequency, etc.). Numeric values may have associated units. Unit values are converted as needed when performing arithmetic operations.

Variables may contain values with units. The units are carried along with the value and applied in subsequent calculations.

More complex units such as velocity (miles per hour, or meters/second) or acceleration (m/s^2) are also supported.

Dates SenseTalk recognizes dates and times in a wide variety of formats, and supports date and time calculations.

Date/time values can be stored in variables, and formats are maintained through calculations.

Chunk expressions SenseTalk's chunk expressions come from its heritage as a member of the XTalk family of languages derived from HyperTalk. Chunk expressions allow working with chunks of text using familiar English terms: characters, words, items, lines. SenseTalk expands upon the original chunk syntax, and extends their use beyond text, to items within a list and bytes within binary data as well.

Chunk expressions can also be used to modify values. In Xtalk language terminology, a chunk of a container (such as a variable) is also a container, so any command that changes the value of a container can also be used to change a chunk.

Files SenseTalk includes commands for opening, reading, and writing files. A text file can be treated as a container (like a variable), so the file contents can be read by simply putting the file into a variable. Similarly, writing a file can be accomplished by putting a variable or other expression into the file.

Because a file is a container, any command that modifies a container can be used directly on a file.

… excerpt ends here. Continue reading the full article.

Illustrations

SenseTalk illustration

Worked examples

Example 1 — a first encounter with SenseTalk

Start with the simplest possible case. Write down what SenseTalk claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to SenseTalk before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about SenseTalk ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of SenseTalk

In research
SenseTalk appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses SenseTalk in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
SenseTalk is common in secondary-school and first-year university syllabi. It links to neighbouring topics Programming languages, Scripting languages, XTalk, so understanding it makes those chapters shorter.
In everyday life
Look for SenseTalk outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “SenseTalk” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study SenseTalk in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what SenseTalk means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain SenseTalk out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is SenseTalk in simple terms?

SenseTalk is a high-level English-like scripting language in the XTalk family, that supports both procedural and object-oriented paradigms. SenseTalk scripts are intended to be largely readable by ordinary people, including those with little to no training in programming.

Why does SenseTalk matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study SenseTalk?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on SenseTalk.

Tags

  • Programming languages
  • Scripting languages
  • XTalk

Keep exploring