Safe mode: Difference between revisions

m
(Created Nim answer.)
 
(4 intermediate revisions by 4 users not shown)
Line 38:
}
</syntaxhighlight>
 
=={{header|C3}}==
The C3 compiler has a `--fast` and a `--safe` mode respectively. The latter, intended for development, enables a wide range of checks from out-of-bounds checks and null dereference checks to runtime contracts with full stacktraces.
 
<!-- == Free Pascal == -->
Line 89 ⟶ 92:
'cgo' is Go's bridge to using C code. As such it is just as unsafe as writing C code directly.
 
=={{header|JsishJ}}==
The ''security level'' (default: 0) can be increased to 1 by executing:
<syntaxhighlight lang="j">(9!:25) 1</syntaxhighlight>
Afterwards, all verbs able to alter the environment outside J are prohibited. See the [https://code.jsoftware.com/wiki/Vocabulary/ErrorMessages#security J Community Wiki] for details regarding the restrictions.
 
=={{header|Jsish}}==
The '''jsish''' interpreter allows a '''-s''', '''--safe''' command line switch to restrict access to the file system.
 
Line 116 ⟶ 123:
 
<syntaxhighlight lang="javascript">var interp1 = new Interp({isSafe:true, safeWriteDirs:['/tmp'], , safeReadDirs:['/tmp']});</syntaxhighlight>
 
=={{header|Julia}}==
Julia does not have a "sandbox" mode that restricts access to operating system resources such as files, since this is considered to be the province of the underlying operating system. Julia does have functions that handle underlying OS memory resources similar to C type pointers. Such functions, including <pre> unsafe_wrap unsafe_read unsafe_load unsafe_write unsafe_trunc unsafe_string unsafe_store! unsafe_copyto! </pre> are prefixed with "unsafe_" to indicate that a memory access fault could be generated if arguments to those functions are in error.
 
=={{header|Nim}}==
Nim doesn’t provide safe mode, but it make a distinction between safe and unsafe features. Safe features are those which cannot corrupt memory integrity while unsafe ones can.
which cannot corrupt memory integrity while unsafe ones can.
 
There is currently no restrictions for using unsafe features, but a programmer should be aware that they must be used with care.
used with care.
 
Here are some unsafe features:
 
* The ones dealing with raw memory and especially those using pointers. Note that Nim makes a difference between pointers which allow access to raw (untraced) memory and references which allow access to traced memory.
difference between pointers which allow access to raw (untraced) memory and references which allow access to
traced memory.
 
* Type casting which, contrary to type conversion, is a simple assignment of a new type without any conversion to make the value fully compatible with the new type.
conversion to make the value fully compatible with the new type.
 
* Using <code>cstring</code> variables as no index checking is performed when accessing an element.
4,105

edits