Respond to an unknown method call: Difference between revisions

Content added Content deleted
m (→‎{{header|JavaScript}}: Clean up the wording...)
m (Fixed lang tags.)
Line 17: Line 17:
(format nil "Do something to ~w." thing))</lang>
(format nil "Do something to ~w." thing))</lang>


Evaluating <lang lisp>(list (do-something 3) (do-something 4))</lang> produces
Evaluating<lang lisp>(list (do-something 3) (do-something 4))</lang> produces


<lang lisp
<lang lisp>("Do something to 3."
>("Do something to 3."
"No method for #<STANDARD-GENERIC-FUNCTION DO-SOMETHING 214FC042> on (4).")</lang>
"No method for #<STANDARD-GENERIC-FUNCTION DO-SOMETHING 214FC042> on (4).")</lang>


Line 117: Line 116:
=={{header|OCaml}}==
=={{header|OCaml}}==
It is not possible in OCaml to call an undefined method, it will fail when trying to compile the code with an error message:
It is not possible in OCaml to call an undefined method, it will fail when trying to compile the code with an error message:
Error: This expression has type example
<lang ocaml>Error: This expression has type example
It has no method ding
It has no method ding</lang>


=={{header|Perl}}==
=={{header|Perl}}==
Line 227: Line 226:
Here is an example of unknown methods being used to call shell commands (this is already defined in the base image):
Here is an example of unknown methods being used to call shell commands (this is already defined in the base image):


<lang slate>
<lang slate>define: #shell &builder: [lobby newSubSpace].
define: #shell &builder: [lobby newSubSpace].


_@shell didNotUnderstand: message at: position
_@shell didNotUnderstand: message at: position
Line 251: Line 249:
ifFalse: [args do: [| :arg | command ; ' ' ; arg]]]]] writingAs: String)
ifFalse: [args do: [| :arg | command ; ' ' ; arg]]]]] writingAs: String)
ifNil: [resend] ifNotNilDo: [| :cmd | [Platform run: cmd]]]
ifNil: [resend] ifNotNilDo: [| :cmd | [Platform run: cmd]]]
].
].</lang>
</lang>


Here is an example of it being used:
Here is an example of it being used:


<lang slate>
<lang slate>slate[1]> shell ls: '*.image'.
slate[1]> shell ls: '*.image'.
kernel.new.little.64.1244260494374694.image slate2.image
kernel.new.little.64.1244260494374694.image slate2.image
net.image slate.image
net.image slate.image
True
True
slate[2]>
slate[2]></lang>
</lang>


=={{header|Smalltalk}}==
=={{header|Smalltalk}}==