single: osh
.. _label7:
-7. さらなる言語例
+さらなる言語例
=======================================
.. In this section, we'll explore the core language through a series of examples (examples of the build system are the topic of the Chapter 3).
.. _label7.1:
-7.1 文字列と配列
+文字列と配列
---------------------------------------
.. The basic OMake values are strings, sequences, and arrays of values. Sequences are like arrays of values separated by whitespace; the sequences are split on demand by functions that expect arrays.
.. _label7.2:
-7.2 クオート文字列
+クオート文字列
---------------------------------------
.. A String is a single value; whitespace is significant in a string. Strings are introduced with quotes. There are four kinds of quoted elements; the kind is determined by the opening quote. The symbols ' (single-quote) and " (double-quote) introduce the normal shell-style quoted elements. The quotation symbols are included in the result string. Variables are always expanded within a quote of this kind. Note that the osh(1) (Chapter 15) printer escapes double-quotes within the string; these are only for printing, they are not part of the string itself.
.. _label7.3:
-7.3 ファイルとディレクトリ
+ファイルとディレクトリ
---------------------------------------
.. OMake projects usually span multiple directories, and different parts of the project execute commands in different directories. There is a need to define a location-independent name for a file or directory.
single: foreach()
.. _label7.4:
-7.4 イテレーション、マップ、foreach
+イテレーション、マップ、foreach
---------------------------------------
.. Most builtin functions operate transparently on arrays.
single: 遅延評価変数
.. _label7.5:
-7.5 遅延評価式
+遅延評価式
---------------------------------------
.. Evaluation in omake is normally eager. That is, expressions are evaluated as soon as they are encountered by the evaluator. One effect of this is that the right-hand-side of a variable definition is expanded when the variable is defined.
.. _label7.5.1:
-7.5.1 遅延評価式についての追加例
+遅延評価式についての追加例
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. Lazy expressions are not evaluated until their result is needed. Some people, including this author, frown on overuse of lazy expressions, mainly because it is difficult to know when evaluation actually happens. However, there are cases where they pay off.
single: while
.. _label7.6:
-7.6 スコープとエクスポート
+スコープとエクスポート
---------------------------------------
.. The OMake language is functional (apart from IO and shell commands). This comes in two parts: functions are first-class, and variables are immutable (there is no assignment operator). The latter property may seem strange to users used to GNU make, but it is actually a central point of OMake. Since variables can't be modified, it is impossible (or at least hard) for one part of the project to interfere with another.
single: Shell
.. _label7.7:
-7.7 シェルエイリアス
+シェルエイリアス
---------------------------------------
.. Sometimes you may want to define an alias, an OMake command that masquerades as a real shell command. You can do this by adding your function as a method to the Shell object.
single: stderr
.. _label7.8:
-7.8 簡単に入出力のリダイレクションを行う
+簡単に入出力のリダイレクションを行う
-----------------------------------------
.. As it turns out, scoping also provides a nice alternate way to perform redirection. Suppose you have already written a lot of code that prints to the standard output channel, but now you decide you want to redirect it. One way to do it is using the technique in the previous example: define your function as an alias, and then use shell redirection to place the output where you want.