Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Eiffel (programming language)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Void-safe capability=== {{Further|Void safety}} Void-safe ability, like static typing, is another facility for improving software quality. Void-safe software is protected from [[Execution (computing)#Runtime|runtime]] errors caused by calls to [[null reference|void references]], and therefore will be more reliable than software in which calls to void targets can occur. The analogy to static typing is a useful one. Void-safe ability can be seen as an extension to the type system, or a step beyond static typing, because the mechanism for ensuring void safety is integrated into the type system. The guard against void target calls can be seen by way of the notion of attachment and (by extension) detachment (e.g. detachable keyword). The void-safe facility can be seen in a short re-work of the example code used above: <syntaxhighlight lang="eiffel"> some_attribute: detachable SOME_TYPE use_some_attribute -- Set value of some_attribute to `v'. do if attached some_attribute as l_attribute then do_something (l_attribute) end end do_something (a_value: SOME_TYPE) -- Do something with `a_value'. do ... doing something with `a_value' ... end </syntaxhighlight> The code example above shows how the compiler can statically address the reliability of whether <code>some_attribute</code> will be attached or detached at the point it is used. Notably, the <code>attached</code> keyword allows for an "attachment local" (e.g. <code>l_attribute</code>), which is scoped to only the block of code enclosed by the if-statement construct. Thus, within this small block of code, the local variable (e.g. <code>l_attribute</code>) can be statically guaranteed to be non-void (i.e. void safe).
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)