prev | next | contents


Part C: ALPHABETICAL REFERENCE.

   Here is the list of all supported symbols and keywords, with detailed meaning, Usage notes (when applicable) and examples.

   In this section, function internally supported by Euphoria are not listed. Please refer to the documentation provided for these by RDS, the company that develops and distributes Euphoria (www.rapideuphoria.com).

   I/O, math, C interfacing and machine-level routines will not be listed here. This may change in future versions of OpenEuphoria documentation, as implementation choices are being made.


+ operator

   Adds two atoms together. The result is represented as an integer of any size if possible; otherwise, a floating point is returned instead.

   Usage notes:

   A + sign not preceded by an identifier is valid; 0 is assumed, so +5 equals 5.

   Example:

?5+7 -> 12 ?+3 -> 3


- operator

   Adds the negative of the second atom to the first. The returned result is an integer whenever possible.

Usage notes: same as +.

   Example:

   ?5-7  -> -2
   ?-3   -> -3

* operator

   Multiplies two atoms together. The returned result is an integer whenever possible, and a floating point number otherwise.

   Example: ?-5*7 -> -35
?3.2*20 -> 64


/ operator

   Divides the leftmost atom by the rightmost atom and returns a floating point number.

   Usage notes:

If the right operand is 0, an exception is raised.
Use the floor and ceiling functions to get integer quotients.

See also: floor, ceiling

   Example:

?5/3 -> 1.666666666...
?16/4 -> 4.0 --not an integer


& operator

   Concatenates two entities.

   Usage notes:

   The left operand must be a type whose length may vary. If it has a common element type, the right operand must be of this type.

   The result of s1&x has length length(s1)+length(x) if x is nonatomic, length(s1)+1 if x is atomic.

   The last element of s1 & x is always the atom x or the last element of x.

See also: append, prepend

   Example:

   {5,8,11} & -3 = {5,8,11,-3}
   {5,8,11} & {7,-3} = {5,8,11,7,-3}
   "albert" & "zoe"  = "albertzoe"


&& operator

   Performs a bitwise and between both operands.

   Usage notes:

   If the atoms are stored with different sizes,, the shorter operand is notionally extended by 1's on the left before the operation.

   Example:

27 && 41 = 9 (in binary form , 27 has its six last bits equal to 011011, while they are 101001 for the second operand. The result has its six last bits equal to 001001. All other bits are zero.


|| operator

   Performs a bitwise or between both operands.

   Usage notes:

   If the atoms are stored with different sizes,, the shorter operand is Notionally extended by 0's on the left before the operation.

   Example:

27 || 41 = 59 (in binary form, 27 has its six last bits equal to 011011, while they are 101001 for the second operand. The result has its six last bits equal to 111011. All other bits are zero.


~~ operator

   Performs a bitwise xor between both operands.

   Usage notes:

   If the atoms are stored with different sizes,, the shorter operand is notionally extended by 0's on the left before the operation.

   Example:

27 ~~ 41 = 50 (in binary ofrm , 27 has its six last bits equal to 011011, while they are 101001 for the second operand. The result has its six last bits equal to 110010. ALL other bits are zero.


^ operator

   Inverts all bits of the only operand. On an integer greater than zero, this amounts to negate it, then add 1. Otherwise, negate the integer and substract 1.

   Example:

^27 = -26
^x = x ~~ -1 --true whatever x is.


<< operator

   Shifts an atom a by n bits to the left.

   Usage notes:

n must be an integer.
If n is negative, a<<n is equal to a>>-n.
Shifting an integer by n positions to the left amounts to multiplying it by power(2,n).

   Shifting a floating point number may yield strange results. This operation is recommended on integers only.


>> operator

   Shifts an atom a by n bits to the right, padding with 0's. If a is an integer, the integer returned has the same initial size as a.

   Usage notes:

n must be an integer.
If n is greater than the number of bits a is stored into, 0 is returned.
If n is not zero, the result is an nonnegative integer. Use the signed shift operatorto get a more expected result on a negative integer.

If n is negative, a >> n is equal to a << -n. Shifting a floating point number may yield strange results. This operation is recommended on integers only.

See also: <<, >>>

   Example:

-257 >> 3 = 32 -- -257 is a 32-bit integer, so the shift is computed over 32 bits.


>>> operator

   Shifts the atom a by n bits to the right, padding with the leading bit of a.

   Usage notes:

n must be an integer.
If n is less than zero, a >>> n returns a << -n. Shifting a floating point number may yield strange results. This operation is recommended on integers only. It then amounts to taking the integer quotient of the left operand by power(2,n).

   Example:

-257 >>> 3 = -32


+=,-=,*=,/=,&=,&amp;&=,||=,~~=,^= assignment

   Shorthand for the corresponding three term operation when the result is the first operand. These forms are generally more efficient and save some typing.

   For instance, x*=y is short for x=x*y.


=,:= assignment

Assignment operator: x gets the same value as y, and any value x had is lost forever.

   Usage notes:

The := synonym is needed when = is clearly a relational operator.


=,!= relational operator

   Compariso operator. (x=y) is equal to 1 if x and y are equal, and to 0 otherwise. (x!=y) is always 1-(x=y).

   Usage notes:

For nonatomic types, equality means equality of all elements.
For nonatomic types, Euphoria returns a sequence of 0's and 1's. This Behaviour can be forced back using the "with seq_compat" or "with EU" directives.

Atoms are never equal to non-atoms. Atoms are equal when they resolve to the same value: the integer 5 equals the floating point number 5.0.

When the "with rounding" directive is on, floating point numbers are rounded to the nearest multiple of the system variable FloatRoundingEpsilon before being compared. By default, this is turned off for compatibility reasons, and can be turned on and off using the "with rounding" directive.


<,<=,>,>= relational operator

   Inequality test operators. For instance, x<y is 1 if x is less than y, and 0 otherwise.

   There are obvious identities:

      (x>y) + (x<y) + (x=y) = 1
      (x!=y) = (x<y) + (x>y)
      (x<=y) = 1 - (x>y)
      (x>=y) = 1 - (x<y)

   Usage notes:

   For nonatomic data types, the order relation used to compare them is lexicographic. This means that strings will be ordered just like they are in a dictionary.

   Notionally, elements are successively compared in the order they appear while they are equal.

   The process terminates when:

   Euphoria returns a sequence, since it extends relational operators to sequences like it does for other operations. You can force this behaviour back using the "with seq_compat" or "with RDS" directives.

   When the "with rounding" directive is on, floating point numbers are rounded to the nearest multiple of the system variable FloatRoundingEpsilon before being compared. By default, this is turned off for compatibility reasons.

   See the entry for rel_eq below.


#({general_identifiers})[operator]=expr assignment

   Simultaneously assigns the value of the righthand expr to all variables after the # sign.

   Example:

   #(x,y,...z)=27    -- the variables x, y,..., z are all set to 27.

#(list)#[operator]=expr assignment

   The righthand side is a nonatom. Each element in the lefthand list is assigned the matching element in the righthand expr, until one or both operand runs out of elements.

   Usage notes:

   The _ sign may appear in the lefthand list as an identifier. This causes the matching element on the right to be ignored. Without the operator, this is the symmetric operation of assigning an explicit sequence of symbols to a single sequence.

   Examples:

#(x,y)#={y,x} swaps symbols x and y.
If s is a sequence, the statement #(x,_,y)#=s will cause x to get s[1] if s is not empty, and y to get s[3] if s is long enough. No error will be raised because of the length of s, since extra arguments are simply ignored.

analyze_id(id)variabes, function

   Returns a triple {name,index,>value }. name is the name of the variable or named nonatom element referred to. If dealing with an element of some nonatom, index is the index of the element in that nonatom, and parent is the id of that nonatom.

   Usage notes:

   Unnamed nonatom elements return a name of "".

   For variables, index is 0 and parent is id.

   Recursively calling analyze_id until the latter condition occurs yields the indexing sequence to apply to the root nonatom in order to access an element nested in tht nonatom and of which only the id is known.


andlogical

   Performs a bitwise and between its two operands. Each bit of the result is set if and only if matching bits of both operands are set. Otherwise it is cleared. Returns False if the result is 0, and True otherwise.

   Example:

27 and 41 = True there is at least one bit set in both operands at the same position, namely bit #1.


and_bits(expr1,expr2) logical, function

Performs a bitwise and between both operands. So and_bits(x,y) = x && y.


append(expr1,expr2) sequences, function

   Returns expr1 after expr2 was added to it as its last element. From this description, expr1 must be a sequence.

   Usage notes:

   There is no restriction on expr2.

   The length of the returned sequence is 1+length(expr1) always.
When expr2 is an atom, append(expr1,expr2)=expr1 &expr2.

   Example:

append("albert","zoe") = {'a','l','b','e','r','t',"zoe"}. This is not a string because the last element of the result is a string, not a char.

break [label|number] flow

   Exits the designated select statement. Execution resumes at the first statement following the next end select statement.

   See the select entry.


but particle, globals

   Specifies that the first argument to promote or demote is an exclusion list Rather than an inclusion list.

See also: demote, promote.


by particle, loops

   Optional part of the for block parameter, introducing the increment for the loop index.

   An increment of 1 is assumed whent this clause is not used.

See also: for


byref, byval prefix, calls

   When a (possibly indexd) variable is given as an argument to a routine, and the formal parameter of the routine to which it is mapped is declared as update, it must be preceded by one of byref or byval. byref means that the variable is indeed to be passed by reference; byval means that only the value is passed, as if there were no update.

   If an expression other than a single variable is mapped to a formal parameter of a routine declared as update, the keyword byval can still be used to emphasize that only a value is passed. A byref keyword in this context causes an error.


call_func(expr,list)
call_proc(expr,list)
call_routine(expr,list)
dynamic

   Calls the routine whose id is given by expr using the argument list list. If the routine does not take any argument, list must be {}.

   call_proc can be used if the routine is a procedure, and call_func can be used for functions and types. They are provided for compatibility only.


case shortcond: subblock

   case statements only appear inside select blocks. They introduce statements to be executed when the selector expression (the expr in select expr) satisfies shortcond.

   Usage notes:

A shortcond is an abbreviated form of a condition. Four forms are recognized:

  • case expr: -- stands for "if selector=expr then...."
  • case rel_op expr: --stands for "if selector rel_op expr then ..."
  • case expr1 thru expr2: --stands for "if expr1<=selector and selector<=expr2 then ..."
  • case expr:, where expr refers to the anonymous variable "_" --stands for expr where selector substitutes "_".

   In the above, selector refers to the selector expression in the ambiant select statement.

   After a case statement executes, control falls through to the next case statement, unless a break statement was encountered. The break statement exits the current select block. The statements following case are executed until their natural end, or at a stop statement.

See also: select, thru, break, stop.


cast(general_identifier,expr1,expr2) sequences, types

   Sets the type information of the element numbered expr1 of the nonatom general_identifier to expr2. Yhis may be needed when the known type information is richer than the standard assumptiion and needs to be kept.

   Usage notes:

   A type check will be performed after this call completes, using the current value and the supplied type information. expr2 is the routine id of the type function to be used, or the type name.


check other prefix, types

   This prefix applies only to types and reftypes. It causes type checks on assignment to variable of the prefixed types to happen regardless of whether systematic type checking is in force.


compare(expr1,expr2) relational function

Compares the two objects given as its arguments, and returns an integer.
The returned value is -1 if the first object is less than the second, 1 if it is greater and 0 if they are equal.

   Note that testing for equality of floating point numbers can be tricky because of rounding errors.


[global ]constant {[type ]identifier=expr} var_decl

   Declares a (list of) constant(s). Constants are symbols whose values cannot be modified.

   The type of the constants can be specified. Otherwise, they are only assumed to be objects.


del_var(expr) operator var-decl

   Deletes a variable that was created using new_var. An exception will occur on any attempt to delete any other sort of variable. Additionally, this procedure cannot be called on a symbol being shadowed.

   expr evaluates to the id of the variable to destroy. This procedure does not return anything.


demote [but] "{identifier}"|identifier [from identifier]
demote _ from identifier
globals

   Removes a symbol from the default namespace, thus making it unavailable without a prefix.

   The syntax is the same as for promote.

   Usage notes:

   When the but keyword is used, the from identifier clause is mandatory.

   The '_' catchall symbol stands for "all symbols from".

   A symbol can be demoted if and only if it has a source namespace. Otherwise, this statement has no action.

See also: promote


do other

   Signals the end of loop parameters.


else flow

   Marks the start of the optional part of an if block that is executed if none of the conditions specified in the if or elsif statements in the current if block was met.

   Usage notes:

   This statement can appear only once in an if block. It can be reached only From an if or elsif statement.

See also: if, elsif.


elsif cond then operator subblock

Checks if the condition cond is met.
If so, execution starts right after the then, exactly as for an if statement. otherwise, if there is still another uninspected elsif statement in the current if block, that statement get executed.

   Otherwise, the if block is exited.

   Usage notes:

   This statement may appear only in an if block, and can be reached only From an if or elsif statement.

   See part A, chapter 5 "Condition evaluation" for details on what cond may be.

See also: elsif, else


end flow

   Marks the end of a block, and must be followed by the block type name. It belongs to the following list: for, if, scope, select, wfor, while, plus all routine type keywords.

   Failing to close a code block with the corresponding end statement causes a syntax error.


equal(expr1,expr2) >
operator logical, function

   Returns True if both expressions have the same value, and False otherwise. Numerical values in different format, as the integer 5 and the floating point number 5.0, have the same value, and hence are equal.<

See also: compare.

error(expr) procedure

   Passes a string as an error message to the RaisedError handler, so that it can display before the program aborts. The error routine is to be used mainly when there is hardly anything else to do but end the running program. Built-in routines invoke it, and any routine can use it, for a variety of software-detected error conditions.


execute(expr) dynamic

   Executes statements specified by the argument string.

   Usage notes:

   The argument expr must evaluate to a string. That string is then treated as if it had been in the source file, even though it results from evaluating an expression.

   This feature may not be supported by translators, which work on source files before they are compiled or run.


exif [number|identifier] flow

   Exits an if block. Same operation as exit, except that it applies to if blocks rather than loops. See below.


exists(expr) function

   The argument must evaluate to a string. The function returns True if there is either a routine or variable in scope with this string as a name. Otherwise, it returns False


exit [number|identifier] flow

   Exits the specified loop. Execution resumes right after that loop ends.

   Usage notes:

   exit without argument means "exit the current loop"
.

   exit with a nonnegative argument n causes n extra levels of loop to be exited at the same time. So, exit 0 is the same as exit, exit 1 exits the loop above the current one and so on. Assume the loops form a sequence starting at 0 with the current loop; then, the argument to exit is the index of the exited loop in this sequence.

   exit with a negative argument n leaves all active loop blocks except the -n-1 topmost such blocks. So, exit -1 leaves all loops, exit -2 causes execution to resume in the topmost Loop, right after the end of the active loop directly nested in that topmost Loop, and so on. This is just counting the loops backwards in the 0-based sequence suggested in the paragraph above.

   exit with an identifier as argument will exit the loop that has the argument as label. See the label entry below.

   Exiting a nonactive or nonexisting loop causes an exception.

   See also: label.


find(expr,expr) sequence handling

   Returns the position of the first occurence of the first argument in the second, and 0 if no occurrence can be found.

   Usage notes:

The second argument must be nonatomic.
If it has nonatomic elements, they are recursively scanned for the sought after object, so that, in this case, it is not necessarily true that expr2[find[expr1,expr2)]=expr1. The index may well be out of bounds!


find_all(expr,expr) sequence handling

   Same as find(), but returns the sequence of all positions of the first argument as an element of the second one.

   Usage notes:

   {} is returned if not a single element of the second argument equals the first one.


fit(target,source,padding|_) assignment

   Assigns to target the part of source that fits into target. If target is longer than source, the remaining elements of target are set to padding, or left alone if the universal _ is used as a third argument.


for loop

   A for loop is a block of code executed a fixed number of times. It has the following form:

   for identifier=start value to end value [by increment] do general-code end for

   Here, identifier is an atomic loop index variable whose initial value is start value. start value, end value and increment are computed once per loop execution, at the time when the for statement is reached from outside the for block. If no by clause is present, increment is set to 1.

   If (start value-end value)*increment is greater than 0, the loop is exited without any iteration taking place, because end value cannot be reached from start value by adding any positive number of increment to it.

   Whenever execution reaches the end for statement, the value of increment is added to the loop index variable. The new value is then compared to tart value and end value.

   If the loop index value is not between these two bounds, the loop is exited and execution resumes right after the end for. Otherwise, another iteration starts right after the do using the new index value.

   The loop index variable cannot be modified inside the loop. Loop index variables should not be declared. They are available in the for loop they are defined in, and remain available until the next for statement using the same loop index identifier.


forward operator prefix, routines

   Specifies that the statements of the routine being defined are not immediately Following the current routine definition. They will follow a short declaration.

   See chapter 8 in part A for details.


[global ][forward ]function identifier({[update ][type ]identifier})
function identifier
routine

   The first form defines the status and the formal parameters of a routine. It is followed by the routine's statements if the forward keyword is not used. The second form introduces the routine's statements if it was defined as forward.

   A function is a routine that must return a value. Provided for compatibility only.

   See part A, chapter 8 for more details.


get_handler(expr) events, ,function

   Returns the id of the handler for the event name expr resolves to, or -1 if none.

   See part A, chapter 11 for details on events and handlers.


get_meta("name"|expr) symbols

   Returns a record of metadata for the symbol whose name or id is given to the function.

   Usage notes:

   The type of returned data is either SystemVarData (described in part A, 5.1) if the symbol is a variable, or SystemRtData (described in part A, 8.8) if the symbol is a routine.


get_name(expr) routine, function

   Returns the name of the routine whose id expr evaluates to. IF no such Routine exists, the empty string "" is returned.<


get_var(expr) +
variable, function

   This function returns the value of the variable whose id expr evaluates to. Remember that ids are integers.

See also: set_var


global prefix

   Specifies that the symbol(s) to which it applies can be seen from other files, possibly using a namespace prefix.

See also: include, import.


[global ][forward ]handler identifier(arguments)
handler identifier
event, routine

   A routine primarily intended to be triggered by an event, as opposed to the other sorts of routines which are primarily intended to be called explicitly.

   See part A, chapter 11 for details, and particularly the layout of arguments.


id("general_identifier"|expr) variable, function

   Returns the id of the specified variable, whose name may be given as a constant (first form) or an expression (second form).

   If no variable with the supplied name exists, -1 is returned.


if

bock

Checks if the condition cond is met.
If so, execution starts after the then until the next elsif, else or end if statement is to be reached. Execution then resumes right after the end if statement.

Otherwise, if there is an elsif statement, this statement is executed.
Otherwise, if there is an else statement, execution starts right after it.
Otherwise, the block is exited.

   Usage notes:

   See part A, chapter 5, "Condition evaluation", for more details on what cond may be.


import filename|(expr) asidentifier globals

   Executes the top level statements in filename if filename is referred to for the first time in a program. If parentheses are used, the string expr must evaluate to is taken as filename.

   Makes the global symbols in filename accessible to the current file. The symbols are available using the prefix identifier:. Unprefixed access is not granted, contrary to what the include statement does.

   Usage notes:

Global named scopes are treated as if imported from a file.
To access imported symbols without any prefix, the promote statement must be used.

   Example:

   import misc.e
--the global symbols in misc.e are available using the prefix misc_e:.

See also: include, promote.


include filename|(expr) [as identifier] globals

   Executes the top level statements in filename if filename is referred to for the first time in a program. If parentheses are used, they enclose an expression wose Value is taken as filename.

   Makes the global symbols in filename accessible to any file in the program without prefix (they are automatically promoted). IF an as identifier clause is specified, the symbols are also available using the prefix identifier: in the file the include statement appears.

   Usage notes:

   Namespaces are known only in the file they appear after an as keyword.

    When a file is included for the first time in a program, its statements are executed. Subsequent including of the same file, whatever the namespaces, does not have this effect.

   Several files may share the same namespace. A file may be included in several namespaces, but the identifiers thus affected are not duplicated.

   Symbols usable without prefix actually belong to a special namespace called default.

See also: import.


insert(target,places,added) sequence handling

   Inserts inside target the elements of the sequence added at the locations specified in the sequence of integers places must evaluate to.

   Usage notes:

added and places must have the same length; otherwise an error occurs.
The sequence places must be strictly increasing; otherwise an error occurs.
Notionally, the last element of added is inserted at the position given by the last element of places. Then, items and places are chopped off, and the process goes on until both items and places are empty.

   The resulting sequence has length(items) more elements than target had when the call was issued.

   insert(s,i,x) equals append(s[1..i-1],x) & s[i..-1], but executes much faster.

See also: insert_sequence


insert_sequence(target,places,added) esquence handling

   Inserts by concatenation inside the target the elements of the sequence added at the locations specified in the sequence of integers to which places must evaluate to.

   Usage notes:

   added and places must have the same length; otherwise an error occurs.
places must be strictly increasing; otherwise an error occurs.
Notionally, the last element of added is inserted by concatenation at the position given by the last element of places. Then, added and places are chopped off, and the process goes on until both added and places are empty.

   The resulting sequence has n more elements than target had when the call was issued. n is the number of atoms in added plus the sum of the lengths of the nonatoms in added.

   insert_sequence(s,i,x) equals s[1..i-1] & x & s[i..-1], but executes much faster.

See also: insert.


is type, particle

   Enables to define an alias for a type or reftype, as described in part A, 1.6. This construct applies to both types and reftypes.

   Example:

	type intSeq is sequence of integer
defines a type function intSeq that checks a value to be a sequence of integer. intSeq can be used from that statement on as an alias for "sequence of integer".

label flow

   Marks a block with the tag identifier, to be used in flow control instructions.


isvarid(expr) dynamic

   Returns True if its argument, which must evaluate to an integer, is the id of a variable, and False else.


length(expr) sequence handling, function

   Returns the number of elements in the nonatom expr. This function fails on atoms, causing an exception.


lock "general_identifier"|expr variables, procedure

   Makes a variable read-only. The variable can be specified either by its name or its id.

   Writing to a read-only variable will cause an exception.


match(expr,expr) sequence handling, function

   Returns the position of the first occurence of expr1 as a subsequence of expr2, or a nonpositive value if none could be found.

   Usage notes:

Both operands must be of nonatomic type.
Because subsequences, and not individual objects, are looked for, there is no recursion as for find, so that, if the function returns a positive value, the subsequence of expr2 starting at the value returned and of length length(expr1) is equal to expr1.

   If expr1 is empty, the matchong does not quite make sense, so a negative value is returned: -1 if expr2 is not empty, and -2 if it is.


match_all(epr,expr) sequence handling, function

   Same as match(), but returns all occurences of the first argument as a slice of the second argument.

   Usage notes:

If the first argument is not a slice of the second one, {} is returned.
If the first argument resolves to the empty sequence, then an atom is returned, with the same values and meanings as for match().


move(target,start,end,where) nonatoms, function

   Moves the slice target[start..end] to position where in target.

   Usage notes:

   If the end of the moved slice has an index higher than length(target), which happens if where+end-start-1 is greater than length(target), an error is raised. Otherwise, the functions acts by rotating a larger slice of target so that the element at position where in the returned value is target[start].

   example:

	target ="abcdefghi"
	s=move(target,7,9,3)	--s is now "abghicdef"
	s=move(target,2,5,7)	--error, as 'e' ends up at --position 10
	s=move(target,2,6,4)	--s is now "aghbcdefi"
	s=move(target,2,4,7)	--s is now "aefghibcd"

name general_identifier as identifier
rename general_identifier as identifier
unname general_identifier
variables

   Allow to specify and manage aliases for elements of nonatoms. The second identifier acts as a record member name.

   name defines an alias, rename changes it and unname discards it.

   The member name tracks the element it tags. For instance, assume the following statement is issued:
name s[3][5] as s35 After that, s[1] is deleted, and then two elements are prepended to the new s[2]. Then, s35 refers to s[2][7], as it is the place the element tagged as s35 lies now.


new_var(varname,vartype,value|_) var_decl

    Creates a new variable on the spot and return its id. The type of the variable is given by vartype, either by name or by id. The variable name is given by varname. Its initial value, if any, is evaluated by expr. To create a variable without an initial value, use the symbol "_" as third argument.

   A variable created in this way cannot be static or global. It is private if the new_var appears inside a routine;it is public otherwise.


next [expr|identifier] flow

   Skips the remainder of the specofoed loop iteration and start a new iteration, updating indexes and evaluating conditions as needed. Argument are specified exactly as for exit.

   The optional expr specifies the currently active loop block to be affected: the current one has index 0 and the others are numbered upwards. An argument of 0 is assumed if there is none; this stands for "restart the current loop".

   An optional argument of identifier may be given, in which case a new iteration of the loop thus tagged starts if it cn. If there is no active loop with this tag, an error occurs.

See also: retry, exit


not logical

   Reverses each bit of its sole operand, reversing True to False and vice versa.


not_bits(expr) logical, function

Performs a bitwise NOT on its operands, so that not_bits(x) = ^x.

See also: ^.


or logical

   Performs a bitwise or between its two operands. Each bit of the result is cleared if and only if matching bits of both operands are not set. Otherwise it is set. Returns True is the result is nonzero and False otherwise, i.e. when both operands are zero.


or_bits(expr1,expr2) logical, function

Performs a bitwise OR between both operands. So or_bits(x,y) = x || y.

otherwise flow

   Inside a select block, introduces the statements to be executed if no case statement could be executed. This clause is optional.


prepend(s,x) sequence handling, function

   Same as append, except that x becomes the first element of the returned value.


print(expr1,expr2) I/O;&nbs;proedure

Prints to the I/O channel number expr1 the second argument. If the second argument is a variable name, and if its format metadata was

set, its value the format string the variable will print with, as if specified in printf() (see below).

   When the above does not apply and the type of the argument can be inferred, the format metadata string is used to format the output. Otherwise, the default output format for objects is used.


printf(expr1,expr2,general_identifier|{{expr}}) I/O; procedure

   Prints the third argument to the file or device channel specified by expr1, using format string expr2. The short form is allowed only if there is only one format specifier in expr2 and it prints an atom.

   Usage notes:

   A format specifier is a string whose first character is '%'. For this reason, the percent sign must appear as "%%" in a format string. The number of format specifiers in the format string must equal the length of the third argument (or equal 1 if the shorter form is used). The first specifier is appliied to print the first item, the second specifier for the second element and so on.

The basic formats supported are:

              %d - print an atom as a decimal integer
              %x - print an atom as a hexadecimal integer
              %o - print an atom as an octal integer
              %s - print a sequence as a string of characters, or print an atom
              as a single character
              %e - print an atom as a floating point number with exponential
              notation
              %f - print an atom as a floating-point number with a decimal
              point but no exponent
              %g - print an atom as a floating point number using either the %f
              or %e format, whichever seems more appropriate
              %v - use the format string of the variable's metadata @format.
              %t - use the format string of the variable's type metadata @format.

   Field widths can be added to the basic formats, e.g. %5d, %8.2F, %10.4s. The number before the decimal point is the minimum field width to be used. The number after the decimal point is the precision to be used, when applicable.

   If the field width is negative, e.g. %-5d then the value will be left-justified within the field. Normally it will be right-justified. IF the field width starts with a leading 0, e.g.08d then leading zeros will be supplied to fill up the field. IF the field width starts with a '+' e.g. %+7d then a plus sign will be printed for positive values.

   As each format specifier applies to one argument only, printing a string requires the following form: printf(x,"%s",{the_string}). Forgetting the braces will result in printing the first character of the_string only.

   When a variable format metadata is the empty string, print routines fall back on the variable's type format metadata.

   When a type format metadata is the empty string, print routines fall back on the default formatting for objects.

   When an expressionn is to be formatted with a %t or %v specifier, which doesn't make much sense, the default formatting for objects is used instead.


[global ][forward ]procedure identifier({[attr ][type ]identifier})
procedure identifier
routine

   The first form defines the status and the formal parameters of a routine. It is followed by the routine's statements if the forward keyword is not used. The second form introduces the routine's statements if it was defined as forward.

   A procedure is a routine that can't return a value. Provided for compatibility only.

   See part A, chapter 8 "Routines", for more details.


promote [but] "{identifier}"|identifier from identifier
promote _ from identifier
globals

   Makes symbols from an imported abstract file accessible without any prefix, effectively aliasing them in default.

   The first argument is an explicit list if between double quotes, and is an expression evaluating to a sequence of strings otherwise.

   The but keyword says that the first argument is a list of symbols to be excluded from promotion rather than to promote.

The shorter second form makes all symbols available without any prefix.
The last identifier argument is the namespace from which the designated symbols are to be promoted.

See also: demote.


record identifier({type|_ identifier|_}) end record type

   Defines the structure type identifier, which becomes a nonatomic user- Defined type.

   Use of "_" as a type means the type of the member is a context type (see 1.4). The context type is declared as stated in the "reftype" entry below.

   Use of "_" as a name means the member has no name, and can be accessed only through indexing.

   Usage notes:

   A record type layout may contain fields that have the same type as the one being declared.

   Members of record instances can be accessed by indexing or naming.


[check ][forward ][global ]reftype typename(integer identifier1,type identifier2)
reftype typename
tye

   The first form defines the status and the formal parameters of a reftype. It is followed by the reftype's statements if the forward keyword is not used. The second form introduces the reftype's statements if it was defined as forward.

   A reftype is a routine with eactly two arguments that returns a boolean. It may be invoked as any routine, except that it returns a value.

   When a (sub)variable get assigned, the (ref)type function associated to its type is implicitly called, with the id of the assigned variable and the value to be assigned as arguments.

   typename may be in the form structname.membername. In this case,the type function may access the members of the host structure by putting a dot before the names.

   Context types and reftypes are discussed in detail in part A, chapter 1.


rel_eq, rel_ge, rel_gt, rel_le, rel_lt, rel_ne(nonatom,x) logical, function

   Extends the relational operators to nonatomic types. Returns a sequence of booleans, of the same length as nonatom. Thus, assuming x1<x2<x3:

rel_eq({x1,x2,x3},x2)={false,true,false}
rel_le({x1,x2,x3},x2)={true,true,false}
rel_lt({x1,x2,x3},x2)={true,false,false}
rel_ge({x1,x2,x3},x2)={false,true,true}
rel_gt({x1,x2,x3},x2)={false,false,true}
rel_ne({x1,x2,x3},x2)={true,false,true}

   Usage notes:

   The Euphoria idioms nonatom>=x and friends return rel_ge(nonatom,x) and friends when the "with seq_compat" directive is in force.


remove(target,places) sequence handling, function

   Removes from target the elements whose positins are listed in places.

   Usage notes:

   places is an expression that must evaluate to a sequence of integers. target is an expression that must resolve to a nonatom.

   Notionally, places is sorted in decreasing order. Then, the element of target whose index is the first element in places is removed. The process goes on until all elements of places have been considered.

   remove(s,i) equals s[1..i-1] & s[i+1..-1], but executes much faster.

See also: replace.


rename general_identifier as identifier variables

   See name above.


repeat(what,howmany) procedure call sequence handling, function

   Creates a sequence of object whose nowmany terms all equal what.


replace(target,places,items) sequence handling, function

   Replaces, in the argument specified by target, the subsequences specified by places by the elements of items.

   Usage notes:

   places and items must have the same length; otherwise, an error occurs. places must resolve to a asequence of array(2) of integer. An atom x is first replaced by {{x,x}}. An atom x inside places is first replaced by { x,x}.

   If places is not sorted in ascending order, an error occurs.
Notionally, the slice of target whose bounds are the last element of places is removed and the last element of items is insert_sequence()'d at the same position into target. places and items are then chopped off, and the process goes on until both are empty.

   replace can be used on arrays on the condition that the length of the result is the same as the length of target. Otherwise, a type check error occurs.

See also: insert_sequence, remove


resume events, routine

   Exits the current routine and executes again the statement that caused the routine to be executed.

   Usage notes:

This statement is mainly intended for exception handlers.
If resume causes execution of the same statement more than MaxResumeRepeat times in a row, an exception is caused.

resume_execute(expr) events, dynaic

   This statement executes a statement on resuming normal program execution. The argument must evaluate to a string on which execute() is applied.

   This instruiction is intended for handlers only.


retry [number|identifier] flow >

   Skips the remainder of current itertion of the specified loop and restarts the current iteration.

   For for loops, this means the loop index is not updated. For while or wfor loops,this means that the initial test is not performed.

   Specifying the affected active loop is done exactly in the same way as for the exit dtatement.

See also: next, exit.


return [expr] routine

   Exits a routine and optionally sets a value to be assigned after returning, when the routine is called as a function.

   See part A, chapter 8 "Routines" for a description of routine calls and returns.


return_execute(expr) events, dynamic

   This instruction executes statements on returning from a handler. expr must evaluate to a string, on which execute() is applied.

   This statement is intended for handlers only.


reverse(expr) sequence handling, function

   Returns a nonatom of the same length as expr. The first element in the returned value is the last one in expr, the second one in the returned value is the second last in expr, and so on.

   Usage notes:

   As expected, the argument must be a nonatom.


rotate(target,start,end,expr) sequence handling, function

   Rotates a slice of a nonatom specified as target[start..end] by expr positions to the right.

   Usage notes:

   If expr evaluates to a negative number, the slice is rotated -expr positions to the left.

   Example:

s={"Alice","Bernard","Carol","David","Eleanor","Fred"} s1=rotate(s,2,4,2)

-- s1 is {"Alice","Carol","David","Bernard","Eleanor","Fred"}
s={"Alice","Bernard","Carol","David","Eleanor","Fred"}
s1=rotate(s,2,4,-2)
-- s1 is {"Alice","David","Bernard","Carol","Eleanor","Fred"}


rotate8, rotate16, rotate32, rotate64, rotate128(expr1,expr2) operator, function

   Performs a bitwise rotation of the 8 (respectively 16, 32, 64, 128) lower order bits of the value of expr1 by expr2 positions to the right. If expr1 is physically represented by less than the number chosen, it is padded with zeroes on the left before rotate. The result has as many bits as the xx in rotatexx says - 1 byte for rotate8, a word for rotate16, and so on.

   Usage notes:

   Because some machines cannot access 64 or 128 bit quantities directly, rotate64 and rotate128 may not be supported on all platforms or machines.

   Example:

   The letter 's' has ASCII code 115, which reads in binary as 01110011 . It is a quantity that fits into a single 16-bit word, so:


[forward ][global ]routine identifier({[attr ][type ]identifier})
routine identifier

routine

   The first form defines the status and the formal parameters of a routine. It is followed by the routine's statements if the forward keyword is not used. The second form introduces the routine's statements if it was defined as forward.

   A routine may or may not return any value, and thus can be called both as a procedure and as a function.

   See part A, chapter 8 "Routines", in part A for more details.


routine_id(expr) dynamic

   Returns the id of the routine the name of which expr evaluates to. If no such routine exists in the calling scope, -1 is returned.


[global ]scope [identifier] block

   This statement isolates a section of code. This section may have symbols of its own.

   When the scope has a name and is global, its global symbols may appear outside it as if they came from an external file, using the scope name as a namespace. There is no point in making an unnamed scope global.

   When the scope is inside a routine, it cannot have a name, must hold code allowed in a routine and have its specific variables defined at the top, just like routines.

   Global symbols in named scopes can be accessed from routines or scopes that issue an use identifier statement.

See also: use.


select selector block

   select is a more versatile form of stacked elsif statements. Inside a select block are case statements, which specify things to do if selector meets some condition. If no such case statement was executed, and if an otherwise clause is present, the statements in that clause are executed.

   Each case statement in the select block is inspected. It specifies a condition the selector must meet. It it does, the statements forming this case branch are executed. Then, the next case is inspected, if any, and if the block was not exited.

   The break statement allow to exit a select statement in the same way exit allows to exit a loop.

See also: case, break.


set_handler(event,expr) event, procedure

   Sets the handler for named events. The first argument must resolve to an event name, or to a parenthesized, comma separated list of event names (a string anyway). The second argument must resolve to an integer, the routine id of the handler being put in charge.

   Usage notes:

   Using -1 as the second argument disables any user-defined handler for the specified events, causing default handlers to be called instead, as an event always has some handler.


set_var(expr1,expr2) variable, procedure

   This procedure assigns a value to a variable. expr1 resolves to the id of the variable, and hence must resolve to an integer, while expr2 evaluates to the value to assign.


stop flow

   Allowed only in the code following a case statement. It causes the execution to resume at the next case statement if there is any, or forces exit from the current select block.

   See also: case, select.


then particle

   Signals the end of if block/elsif subblock parameters.

See also: if, elsif


thru operator

   Used in case statements to specify lower and upper bounds for the selector expression in the ambiant select statement.

   See also: case.


to particle

   Part of the for/wfor block parameters, introducing the end value for the loop index.

See also: for, wfor.

[check ][forward ][global ]type name(type identifier)
type identifier
type

   The first form defines the status and the formal parameter of a type. It is followed by the type's statements if the forward keyword is not used. The second form introduces the type's statements if it was defined as forward.

   A type is a routine with eactly one argument that returns a boolean. It may be invoked as any routine, except that it returns a value.

   When a (sub)variable get assigned, the type function associated to its type is implicitly called, with the value to be assigned as argument.

   name may be in the form structname.membername. In this case,the type function may access the members of the host structure by putting a dot before the names.

   See part A, chapter 1 for more details.


unlock "general_identifier"|expr operator

   Makes a previously locked variable writeable again. This call does not affect constants.


unname identifier variables

   See name above.


update prefix

   This keyword must precede any formal parameter passed by reference in a routine definition. Passing a variable by reference means that the modifications the called routine will make to this variable will be preserved on return, while they are not if passed by value.

See also: byref, byval.

use identifier directive

   The identifier is the name of a scope. Global symbols in this scope are accessed from the code following the use statement without any namespace-like prefix.

   This statement appears only in scopes and routines. When the code in that scope or routine stops executiing, the effects of the use statement stop as well.

See also: scope.

var(expr) variables, function

   Returns the name of the variable whose id expr evaluates to. If the variable does not exist for any reason, the empty string "" is returned.


wfor loop

   A wfor loop is a block of code executed as long as its index is between the two bounding expressions in the following complete decription:

   wfor identifier=start value to end value [by increment] do

   Here, identifier is an atomic loop index variable whose initial value is start value. start value, end value and increment are computed before each new loop execution. If there is no by clause, a value of 1 is assumed for the increment.

   If start value-end value has the same sign as increment, the loop is exited without any (further) iteration taking place.

   Whenever execution reaches the end wfor statement, the current value of increment is added to the loop index variable. The new value is then compared to the current values of start vlue and end value, which must be atoms.

   If the loop index value is not between these two values, the loop is exited and execution resumes right after the end wfor. Otherwise, another iteration starts right after do using the new index value.

   The loop index variable is an ordinary variable, previously declared and whose value may be modified inside the wfor loop.


while loop loop

   Repeats a chunk of code until the condition cond is not met.

   A while looop has the general form:
while cond do .... end while

   Usage notes:

   Contrary to the for loop, the while loop has no index variable, and its cond is evaluated each time the while statement is executed.

The end while statement transfers control to the while statement.
See part A, chapter 4 "Condition evaluation", for more details on what cond may be.
The "repeat ... until cond" construct of some languages is easily emulated using a while loop:

repeat something until cond

is equivalent to the more verbose:

while 1 do

do_something
if not cond then exit
end if
end while

with identifier operator

   Specifies that a boolean governing the way the interpreter/compiler works is to be set.

   Usage notes:

The closed list of keywords that can be used as argument to with or without appears in Appendix 2.


without identifier directive

   Specifies that a boolean governing the way the interpreter/compiler works is to be cleared.

   Usage notes:

The closed list of keywords that can be used as argument to with or without is:
  rounding turns rounding of floatiing point numbers before compare on
  RDS combines seq_compat and turns rounding off
  profile turns profiling facility on
  seq_compat turns extension of relational operators to nonatoms on
  trace turns trace facility on
  type_check turns systematic type checking on assignment on
  warning[=list] specifies the warnings to be turned on. No optional list means all kinds of warnings are enabled.

the warnings issued by openeuphoria are as follow:

  • UnusedPrivateVar --a private variable is not referenced in the routine
  • UnusedFormalParm --a routine does not use some of its formal parameter
  • ShadowingDefaultGlobal --a global symbol in default: is being shadowed by another global.
  • ShortCircuitSideEffect --an expression with side effects is bypassed because of short circuit evaluation
  • StatementAfterReturn --rncountered a statement following a 'return" instruction which cannot be executed.
  • VariableIsWriteProtected -- attempt to write to a locked variable.

  - overridingbuiltin -- a symbol from builtin: is being shadowed
xor logical

   Performs a bitwise xor between its two operands. Each bit of the result is set if and only if matching bits of both operands are different. Otherwise it is cleared. Then returns False if the result is 0, and True otherwise. xor is provided for completeness, as it is synonym to =.


xor_bits(expr1,expr2) logical, function

Performs a bitwise XOR between both operands. So xor_bits(x,y) = x ~~ y.




prev | next | contents