No return?

A method that is specified as to have a Return Type the does not execute a return, returns “false”.

Is this a BUG? Or is this a GOT YOU?

it returns the default for whatever the return type is specified as

if you define the method to return a boolean and do not explicitly return a value then it will return false
if you define it to return and int and do not “return” it will return 0
etc

not a bug

This is expected. If the method definition is to return a boolean it will by default return false.

Also, if it’s defined to return an object, it will return nil.

Thanks all.

My understanding of BASIC programing is lacking.

An old assembler coded has a hard time with these HIGH level languages.

Wish there was a BASIC book like the old C small hand book(?) and I had one.

the old C book (K & R) while handy was lacking in a lot of areas too :stuck_out_tongue:

IF you can find one the ancient “REALbasic the definitive guide” still has some useful bits about certain aspects of the language like this that have not changed
Or you can get a used one here http://www.amazon.com/REALbasic-Definitive-Guide-Matt-Neuburg/dp/1565926579

There was a thread, year ago now, where some argued that the compiler should actually complain if you don’t have a return in your function. I can appreciate the argument but I’m sure it would break tons of existing code.

I like this idea, and I don’t think it would break anything as a compiler warning.

It would be a thorny issue
Should a method defined as (this is purely an edge case to illustrate at least one issue)

   Function Foo() as integer
           raise new nilobjectexception
    end function

be flagged as not returning a value ?
It never will return a value since it always raises a new exception - so should this warning persist ?

Then what about callers of foo since they may be completely bypassed since foo always raises an exception
Should they be flagged ?
How would the compiler know (this is a lot harder than you might guess)

Its a very interesting area
And I suspect one we’re not likely to actually implement as it has a bunch of issues like this plus others and some technical impediments

I’d say yes, it should. Similar to how you’d get a “Unused method parameter” warning with this method:

    Function Foo(Bar As Integer) As Integer
       #If False
           Bar = Bar + 1
           Return Bar
       #endif
    End Function

[quote=202434:@Norman Palardy]IF you can find one the ancient "REALbasic the definitive guide " still has some useful bits about certain aspects of the language like this that have not changed
Or you can get a used one here http://www.amazon.com/REALbasic-Definitive-Guide-Matt-Neuburg/dp/1565926579 [/quote]

I’m selling my home and been clean up and trashing some old stuff and came across “Tutorial RealBasic” and a CD for 5.5.

Swift does exactly that… it even complains if the return is inside a conditional, as it might be possible to never be executed

It all comes down to what is a high level language. If the thing is overbearing with ending quotes and the need to return from every function or event, IMHO, it is not a high level language anymore.

Like Jim, I come from an era where we knew on the thumb the processors instruction sets. I am not too sure machine language should be taught to human beings. I am positive in thirty years or so computers have learned how to adapt to human. For all the imperfections it has, Xojo is a brilliant example of such evolution.

Meant semi colon ending lines :wink: Could have mentioned opened and closed braces as well …

How could a language be so dumb it needs to have every line terminated with “;” when VB ages ago was able to use both implicit line ending when only one statement was on a line, and use : between them for multiple statements.

For all the hoopla of new C commands regularly requested for Xojo in this forum, one can really wonder why that age old thing never evolved a single bit in so many years. How come it took so long for Apple to realize that Objective-C was just as antiquated as Latin, to finally condescend offering much more decent and modern Swift ?

Sure
Lots of C /C++ compilers do too
Its just something that, for technical reasons, we can’t do
Code flow analysis & static analysis would be really cool

[quote=202455:@Michel Bujardet]
For all the hoopla of new C commands regularly requested for Xojo in this forum, one can really wonder why that age old thing never evolved a single bit in so many years.[/quote]

“Standards” :stuck_out_tongue:
For all their with sometimes they have been the reason things evolve slowly
The C standard has hardly budged much in years - and a change like not requiring the ; would be an enormous change (plus requiring it makes writing a lexer/parser simpler )

C++ has moved a pile - but not in the area of basic syntax like ;
And that will probably never change either

Swift, being completely new, has the option to drop all that on the floor
And it is evolving very quickly - just look at what Strings used to be and what they are now

[quote=202458:@Norman Palardy]“Standards” :stuck_out_tongue:
For all their with sometimes they have been the reason things evolve slowly
The C standard has hardly budged much in years - and a change like not requiring the ; would be an enormous change (plus requiring it makes writing a lexer/parser simpler )

C++ has moved a pile - but not in the area of basic syntax like ;
And that will probably never change either
[/quote]

I never built more than interpreters so I am probably completely delusional imagining that it could be not that extraordinary to check the presence of a semi colon at the end of a line, and if not present, add it before parsing, either within the compiler, which I suspect to process line by line, or in the editor. The Eclipse IDE does it with plugins http://stackoverflow.com/questions/3418665/how-do-i-get-eclipse-to-automatically-add-a-semicolon It should not be that terrible to do for the major players.

My point is that we all terribly much care about UI, but when it comes to development tools, it seems so many companies, singularly Apple until last year, have an “let them eat cake” philosophy.

Mind you, that is not the case for Xojo, and that is a big part of its attractiveness IMHO. Even if it is not in the top 100 TIOBE index.