Page 2 of 2

Re: Removed autocasting strings

Posted: Tue Apr 09, 2013 8:12 am
by Fred
Actually, disallowing autocasting of pointers makes sens, as you hardly need it unless you are doing very specific debugging.

Re: Removed autocasting strings

Posted: Tue Apr 09, 2013 8:30 am
by Josh
Fred wrote:Actually, disallowing autocasting of pointers makes sens, as you hardly need it unless you are doing very specific debugging.
If there will be a option to disallow auto-casting in future, it would make sense to do this in code and not in the preferences. So there will be no problem to use posted code from the forum.

I'm thinking a parameter or flag for different security levels expanding the EnableExplicit directive would make sense.

Re: Removed autocasting strings

Posted: Tue Apr 09, 2013 9:52 am
by Danilo
Fred wrote:Actually, disallowing autocasting of pointers makes sens, as you hardly need it unless you are doing very specific debugging.
It is not a problem with pointers only. I think you have luis' example in mind: Write *p where you wanted to write *p\s.
It could be a typo, but this can also happen with structures. Not for string concatenation, generally.

Code: Select all

EnableExplicit

Structure Items
    b.b
EndStructure

Structure Entity
    *p.Byte
    b.Items[10]
EndStructure

Define the.Entity

Define byt.b = 12

If byt = the       ; compare byte (.b) with Structure?
    Debug "1"
EndIf

If byt = the\b[5]  ; compare byte (.b) with Structure?
    Debug "2"
EndIf

If byt = the\p     ; compare byte (.b) with Pointer?
    Debug "3"
EndIf

If byt = the\b[5]\b             ; compare byte (.b) with byte (.b), correct
    Debug "4"
EndIf

If the\p <> 0 And byt = the\p\b ; compare byte (.b) with byte (.b), correct
    Debug "5"
EndIf
PB does auto-casting from nearly all to all types. We know that. But a typo is a typo, it is mistake you did not want to write.

Writing *p or x but wanting to write *p\s and x\b can happen everywhere, not for string concatenation only.

Maybe it would be better to allow everything by default (like it is now) for prototyping
and check EVERYTHING with EnableExplicit. In the case of auto-casting to string,
EnableExplicit would mean to have explicitely to use Str(). ;)

Re: Removed autocasting strings

Posted: Tue Apr 09, 2013 10:13 am
by Little John
Josh wrote:If there will be a option to disallow auto-casting in future, it would make sense to do this in code and not in the preferences.
Absolutely!
Josh wrote:So there will be no problem to use posted code from the forum.
I understand what you are saying, but I think then there still will be problems with using posted code from the forum.
Say there will be the keywords "EnableStringAutocasting" and "DisableStringAutocasting". People might use them at the beginning of their main source code file, before any "Include" statement. Then they'll post e.g. a snippet from an include file, which as a small isolated piece of code will not work the same way as in the original context, with "EnableStringAutocasting" or "DisableStringAutocasting" in effect. IMHO this has the potential to cause much confusion.

Re: Removed autocasting strings

Posted: Sat Apr 13, 2013 12:37 pm
by mk-soft
I take back my request to remove the "auto casting".
I like the idea with the "EnableAutocasting, DisableAutocasting".

I first discovered PureBasic for my hobby. In the meantime I use purebasic for special requirements in the industrial application where there are no ready for solving approaches.

The development time of these special applications with purebasic very short.

My request to the PureBasic Team which is the bug reports are processed before any other wish.

Thank you for the best native compiler for all standard OS :wink:

Thanks to google translater

Re: Removed autocasting strings

Posted: Sat Apr 13, 2013 5:40 pm
by Little John
mk-soft wrote:I take back my request to remove the "auto casting".
Then I'll maintain the request. :)

Re: Removed autocasting strings

Posted: Sat Apr 13, 2013 7:00 pm
by buddymatkona
Making new functionality optional when changing existing commands is easier on users, however, having said that...
If you start Debug with a string, you get autocasting. If you don't, you don't. I like it.