Actions
Actions are the lines of code you write that execute whenever a probe is fired. You can assign values to variables, perform computations, and aggregate values over time.
D has no flow control, so there are no if statements and no loops. You can simulate if statements by using predicates, discussed below. The ternary operator (?:) is available, too.
The lack of loops is understandable. DTrace scripts, after they are compiled and verified, are run inside of the kernel. It would be a bad thing to have an unintentional infinite loop occur, locking up the system.
Variables
What is a programming language without variables? D has a number of kinds of variables. Simple (scalar) variables are familiar to those of us used to C, along with structures, ...
Get Advanced Mac OS X Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.