JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Solaris Dynamic Tracing Guide
search filter icon
search icon

Document Information

Preface

1.  Introduction

2.  Types, Operators, and Expressions

Identifier Names and Keywords

Data Types and Sizes

Constants

Arithmetic Operators

Relational Operators

Logical Operators

Bitwise Operators

Assignment Operators

Increment and Decrement Operators

Conditional Expressions

Type Conversions

Precedence

3.  Variables

4.  D Program Structure

5.  Pointers and Arrays

6.  Strings

7.  Structs and Unions

8.  Type and Constant Definitions

9.  Aggregations

10.  Actions and Subroutines

11.  Buffers and Buffering

12.  Output Formatting

13.  Speculative Tracing

14.  dtrace(1M) Utility

15.  Scripting

16.  Options and Tunables

17.  dtrace Provider

18.  lockstat Provider

19.  profile Provider

20.  fbt Provider

21.  syscall Provider

22.  sdt Provider

23.  sysinfo Provider

24.  vminfo Provider

25.  proc Provider

26.  sched Provider

27.  io Provider

28.  mib Provider

29.  fpuinfo Provider

30.  pid Provider

31.  plockstat Provider

32.  fasttrap Provider

33.  User Process Tracing

34.  Statically Defined Tracing for User Applications

35.  Security

36.  Anonymous Tracing

37.  Postmortem Tracing

38.  Performance Considerations

39.  Stability

40.  Translators

41.  Versioning

Glossary

Index

Precedence

The D rules for operator precedence and associativity are described in the following table. These rules are somewhat complex, but are necessary to provide precise compatibility with the ANSI-C operator precedence rules. The table entries are in order from highest precedence to lowest precedence.

Table 2-11 D Operator Precedence and Associativity

Operators
Associativity
() [] -> .
left to right
! ~ ++ -- + - * & (type) sizeof stringof offsetof xlate
right to left
* / %
left to right
+ -
left to right
<< >>
left to right
< <= > >=
left to right
== !=
left to right
&
left to right
^
left to right
|
left to right
&&
left to right
^^
left to right
||
left to right
?:
right to left
= += -= *= /= %= &= ^= |= <<= >>=
right to left
,
left to right

There are several operators in the table that we have not yet discussed; these will be covered in subsequent chapters:

sizeof
Computes the size of an object (Chapter 7, Structs and Unions)
offsetof
Computes the offset of a type member (Chapter 7, Structs and Unions)
stringof
Converts the operand to a string (Chapter 6, Strings)
xlate
Translates a data type (Chapter 40, Translators)
unary &
Computes the address of an object (Chapter 5, Pointers and Arrays)
unary *
Dereferences a pointer to an object (Chapter 5, Pointers and Arrays)
-> and .
Accesses a member of a structure or union type (Chapter 7, Structs and Unions)

The comma (,) operator listed in the table is for compatibility with the ANSI-C comma operator, which can be used to evaluate a set of expressions in left-to-right order and return the value of the rightmost expression. This operator is provided strictly for compatibility with C and should generally not be used.

The () entry in the table of operator precedence represents a function call; examples of calls to functions such as printf() and trace() are presented in Chapter 1, Introduction. A comma is also used in D to list arguments to functions and to form lists of associative array keys. This comma is not the same as the comma operator and does not guarantee left-to-right evaluation. The D compiler provides no guarantee as to the order of evaluation of arguments to a function or keys to an associative array. You should be careful of using expressions with interacting side-effects, such as the pair of expressions i and i++, in these contexts.

The [] entry in the table of operator precedence represents an array or associative array reference. Examples of associative arrays are presented in Chapter 1, Introduction. A special kind of associative array called an aggregation is described in Chapter 9, Aggregations. The [] operator can also be used to index into fixed-size C arrays as well, as described in Chapter 5, Pointers and Arrays.