root@19fc30013016:/home/g/code/tmpex# cat mhello.t

function l_hello()
  --to terra, this effectivly runs at `compile time`, and does not involve
actual
  print("hello from lua")
end

l_hello()
-- this is just normal lua


  --[[

terra bad_hello()
--this is not real terra code, terra does not have a print function
  print("not happening")
end
bad_hello() -- this causes an exception

  --]]
--import a native library
C = terralib.includec("stdio.h")

terra t_hello()
  -- this uses native code imported from a c library
  C.printf("hello from terra\n")
end

--this is a real terra function
t_hello()


root@19fc30013016:/home/g/code/tmpex# terra mhello.t
hello from lua
hello from terra

On Tue, Dec 6, 2016 at 3:40 PM, Will Rubin <[email protected]> wrote:

> Same error only it says printf not found :-(
>
> --W
>
> On 12/6/2016 5:37 PM, S K wrote:
>
>> Use "printf", not "print".
>>
>> -p
>>
>>
>>
>> On Dec 6, 2016, 2:35 PM -0800, Will Rubin <[email protected]>,
>> wrote:
>>
>>> I just can't get it to work. I put the following in to hello.t
>>>
>>> terra hello()
>>> print("Hello, World!")
>>> end
>>>
>>> terralib.saveobj("hello", { main = hello })
>>>
>>> Then run terra hello.t. But I get the following error message:
>>>
>>> C:\Users\zdevito\terra\src\terralib.lua:1097: Errors reported during
>>> typechecking.
>>> hello.t:2: lua object of type function not understood by terra code.
>>> print("Hello, World!")
>>> ^
>>> hello.t:2: to call a lua function from terra first use terralib.cast to
>>> cast it
>>> to a terra function type.
>>> print("Hello, World!")
>>> ^
>>> hello.t:2: expected a function or macro but found lua value of type
>>> function
>>> print("Hello, World!")
>>> ^
>>> [etc.]
>>>
>>> --Will
>>>
>>> On 12/6/2016 3:48 PM, [email protected] wrote:
>>>
>>>> Just like it shows on the website, after you define a main function,
>>>> you’d call
>>>>
>>>> terralib.saveobj("MyExecutable",{ main = myMain })
>>>>
>>>> On Tuesday, December 6, 2016 3:48:07 PM EST Will Rubin wrote:
>>>>
>>>>> I can get the samples to work in the REPL, for example. But how do I
>>>>> turn that into an executable? The guide says "... or even compiled to
>>>>> an
>>>>> executable directly." But I couldn't figure out how to directly create
>>>>> the stand alone Windows executable.
>>>>>
>>>>> --Will
>>>>>
>>>>> On 12/6/2016 3:38 PM, [email protected] wrote:
>>>>>
>>>>>> Will, what you want already exists! Open a terminal/command prompt
>>>>>> and run
>>>>>> `terra`.
>>>>>>
>>>>>> On Tuesday, December 6, 2016 3:39:06 PM EST Will Rubin wrote:
>>>>>>
>>>>>>> If possible, I also would like to see an example of how to create a
>>>>>>> stand-alone executable that includes the Lua interpreter. For
>>>>>>> example,
>>>>>>> the executable could start up and say "Hi from Terra" (from Terrra)
>>>>>>> and
>>>>>>> "Hi from Lua" (from "regular" Lua) without using C or LuaJIT. I
>>>>>>> couldn't
>>>>>>> find an example like this on the Terra site but from the wording
>>>>>>> there
>>>>>>> thought it might be possible.
>>>>>>>
>>>>>>> --Will
>>>>>>>
>>>>>>> On 12/6/2016 2:48 PM, [email protected] wrote:
>>>>>>>
>>>>>>>> On Tuesday, December 6, 2016 11:19:11 AM EST Tyler Brough wrote:
>>>>>>>>
>>>>>>>>> I am very excited to get started using Lua-Terra for my research in
>>>>>>>>> finance. While I know some programming, I am by no means a computer
>>>>>>>>> scientist. I am wondering if you can help install and compile a
>>>>>>>>> "hello
>>>>>>>>> world" application. I am working on both Windows 10 and Ubuntu
>>>>>>>>> linux.
>>>>>>>>>
>>>>>>>>> I really appreciate your guidance!
>>>>>>>>>
>>>>>>>>> TJB
>>>>>>>>>
>>>>>>>> Have you ever used Lua in the past? If so, “Hello world” with Terra
>>>>>>>> is
>>>>>>>> very
>>>>>>>> similar. Would you like to just run your scripts with the `terra`
>>>>>>>> command
>>>>>>>> line program, or would you like to make a standalone program? Both
>>>>>>>> are
>>>>>>>> possible , and very easy, with Terra.
>>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> terralang mailing list
>>>>>>> [email protected]
>>>>>>> https://mailman.stanford.edu/mailman/listinfo/terralang
>>>>>>>
>>>>>> _______________________________________________
>>>>> terralang mailing list
>>>>> [email protected]
>>>>> https://mailman.stanford.edu/mailman/listinfo/terralang
>>>>>
>>>>
>>>>
>>> _______________________________________________
>>> terralang mailing list
>>> [email protected]
>>> https://mailman.stanford.edu/mailman/listinfo/terralang
>>>
>>
> _______________________________________________
> terralang mailing list
> [email protected]
> https://mailman.stanford.edu/mailman/listinfo/terralang
>
_______________________________________________
terralang mailing list
[email protected]
https://mailman.stanford.edu/mailman/listinfo/terralang

Reply via email to