[Gambas-user] Error (or not logic) in sub/function parsing
Leonardo Miliani
leonardo at ...1237...
Mon Nov 22 11:55:20 CET 2010
Copy the following code in a sample form and run it:
PUBLIC SUB Form_Open()
DIM a AS Integer
a = Test_sub()
PRINT a
a = Test_func()
PRINT a
END
PUBLIC SUB Test_sub() AS Integer
RETURN 1
END
PUBLIC FUNCTION Test_func() AS Integer
RETURN 1
END
You'll see two "1" in the Gambas console. I think this is wrong because
a SUB (or Procedure) must not return any value. Instead the Function
works correctly as it is (or it should be) the only one that can (or
could) return a value.
The right way should be that Gambas parser should raise an error when it
finds a "RETURN" statement inside a SUB routine.
--
Leonardo Miliani.
Sito personale: www.leonardomiliani.com
Co-fondatore di www.gambas-it.org
Il portale della comunità italiana dei programmatori Gambas
More information about the User
mailing list