This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Sebra's profile picture

dofile function

Started by Sebra, 10 March 2012 - 05:46 AM
Sebra #1
Posted 10 March 2012 - 06:46 AM
In manual:
dofile ([filename])
Opens the named file and executes its contents as a Lua chunk. When called without arguments, dofile executes the contents of the standard input (stdin). Returns all values returned by the chunk. In case of errors, dofile propagates the error to its caller (that is, dofile does not run in protected mode).
but in bios.lua
dofile = function( _sFile )
  local fnFile, e = loadfile( _sFile )
  if fnFile then
	setfenv( fnFile, getfenv(2) )
	fnFile() --Why not "return fnFile()" here?
  else
	error( e )
  end
end
Why function do not return anything?
Sebra #2
Posted 11 March 2012 - 02:01 PM
Sorry for reply to own topic, but if 40 viewers gives 0 replies seems no pro can/want to answer. :mellow:/>/>
Is it just a mislooked bug and can be fixed immediately?
Espen #3
Posted 11 March 2012 - 02:14 PM
Sorry for reply to own topic, but if 40 viewers gives 0 replies seems no pro can/want to answer. :mellow:/>/> Is it just a mislooked bug and can be fixed immediately?
Well it's not really suprising if you ask me. I don't think anyone who knew wouldn't answer you. I think it's just that nobody knows, because nobody can know.
The question you asked can only really be answered by Dan, since he wrote the code for it. The rest of us can only speculate what his reasons were.
Maybe he just forgot to return the values? Maybe he did it intentionally for some reason?

If you want to ask Dan something directly then I'd suggest paying the IRC channel a visit and ask him there: http://webchat.esper...=#computercraft
(The link to the IRC channel can also be found at the top menu of the computercraft.info main page.)
Sebra #4
Posted 11 March 2012 - 03:36 PM
Thanks for first answer. My hope was some "lua pro" would be up user level. :mellow:/>/>
I wonder did he wrote bios.lua himself or looking in some example?
I see no reasons why to hide result but who knows.
No wonder dan200 has busy state on that chat.