Hostname: Difference between revisions

Content added Content deleted
m (→‎{{header|Wren}}: Minor tidy)
 
Line 1,050: Line 1,050:
However, if Wren is embedded in (say) a suitable Go program, then we can ask the latter to get it for us.
However, if Wren is embedded in (say) a suitable Go program, then we can ask the latter to get it for us.


<syntaxhighlight lang="ecmascript">/* hostname.wren */
<syntaxhighlight lang="wren">/* Hostname.wren */
class Host {
class Host {
foreign static name() // the code for this is provided by Go
foreign static name() // the code for this is provided by Go
Line 1,059: Line 1,059:
which we embed in the following Go program and run it.
which we embed in the following Go program and run it.
{{libheader|WrenGo}}
{{libheader|WrenGo}}
<syntaxhighlight lang="go">/* hostname.go */
<syntaxhighlight lang="go">/* Hostname.go */
package main
package main


Line 1,076: Line 1,076:
func main() {
func main() {
vm := wren.NewVM()
vm := wren.NewVM()
fileName := "hostname.wren"
fileName := "Hostname.wren"
methodMap := wren.MethodMap{"static name()": hostname}
methodMap := wren.MethodMap{"static name()": hostname}
classMap := wren.ClassMap{"Host": wren.NewClass(nil, nil, methodMap)}
classMap := wren.ClassMap{"Host": wren.NewClass(nil, nil, methodMap)}