Page 5 of 6

Re: PureBasic 4.50 is out !

Posted: Sat Jun 12, 2010 2:45 pm
by Seymour Clufley
I think this is a brilliant update.

4.4 was important with maps and the 2D drawing enhancements, but 4.5 is perhaps an even more important update with the new ability to have maps, lists etc. inside structures. For me this is an extremely useful ability that simplifies a lot of work, and drastically reduces memory consumption (compared to static arrays).

Thank you, thank you, thank you!

Seymour.

Re: PureBasic 4.50 is out !

Posted: Sun Jun 13, 2010 12:01 pm
by srod
I agree, one of the most significant upgrades to Purebasic ever. Awesome.

Thanks team. Much appreciated.

Re: PureBasic 4.50 is out !

Posted: Tue Jun 22, 2010 12:16 am
by PrincieD
Seymour Clufley wrote:4.4 was important with maps and the 2D drawing enhancements, but 4.5 is perhaps an even more important update with the new ability to have maps, lists etc. inside structures. For me this is an extremely useful ability that simplifies a lot of work, and drastically reduces memory consumption (compared to static arrays).
Agreed definately! I'm already using maps and lists inside structures in the latest build of ProGUI im working on.

Thanks PB team! :D

Chris.

Re: PureBasic 4.50 is out !

Posted: Tue Jun 22, 2010 6:57 pm
by Flype
Congratulation Fred and Freak for this - must have - release.

All the new stuff is terrific and increase the interest of this language.

It's very pleasant to re-code some old programs cleaner thanks to the new features.

Re: PureBasic 4.50 is out !

Posted: Thu Jun 24, 2010 4:06 am
by akee
Hi! Out of programming habit with VBScript, I discovered this...

Code: Select all

Procedure LOGICAL(a, b)
  ProcedureReturn a = b
EndProcedure

delta = Not LOGICAL(1, 1)

Debug delta
PB Sample produces an error.

Code: Select all

Function LOGICAL(a, b)
  LOGICAL = a = b
End Function


delta = Not LOGICAL(1, 1)

WScript.Echo delta
VBScript does not.

Re: PureBasic 4.50 is out !

Posted: Thu Jun 24, 2010 7:17 am
by blueznl

Code: Select all

Procedure LOGICAL(a, b)
  ProcedureReturn a = b
EndProcedure

delta = Not LOGICAL(1, 1)

Debug delta
Dunno, but that is entirely unsensible code :-) so I'll forgive PureBasic for throwing an answer :-)

Let's start by turning this line

Code: Select all

ProcedureReturn a = b
into

Code: Select all

ProcedureReturn b
Then NOT is a keyword only used in combination with conditions, such as IF. PB doesn't do boleans, only ints and floats. Your procedure returns an integer, and how can one invert an integer? One cannot. Well, perhaps you could do something like this:

Code: Select all

Procedure LOGICAL(a, b)
  ProcedureReturn b
EndProcedure

delta = 0-LOGICAL(1, 1)

Debug delta
Better post this in the questions section next time I guess :-)

Re: PureBasic 4.50 is out !

Posted: Thu Jun 24, 2010 9:51 am
by Melissa

Code: Select all

Procedure LOGICAL(a, b)
  ProcedureReturn b
EndProcedure
Image

Code: Select all

Procedure LOGICAL(a, b)
if a = b : ProcedureReturn #True : EndIf
EndProcedure

delta = (Not LOGICAL(1, 1))

Debug delta
...Simple as that.

Re: PureBasic 4.50 is out !

Posted: Thu Jun 24, 2010 7:37 pm
by blueznl
True, but what I wanted to show is that you should not use a = b as a procedure return value. People should stop asking if the following works:

a = (a = b )

BECAUSE IT DOESN'T.

It's everywhere, in the docs, in the FAQ, even in my pathethic survival guide. I'm tempted to suggest to Fred to put a new feature in: whenever the demo or the normal version of PureBasic is started for the very first time, it should load a demo program that goes something like this:

Code: Select all

  ; please examine this example code carefully
  ; 
  ; a = (a = b )  ; <== THIS DOES NOT WORK. NO. IT DOESN'T. IT WON'T. IT WILL NOT BE SUPPORTED.
  ;
  ; please read the manual or visit the forum
I don't mind questions, no matter how dumb, but this one is so all over the place that it's frankly a little annoying.
Pfff.

I think I had a bad day :-)

Re: PureBasic 4.50 is out !

Posted: Fri Jun 25, 2010 6:28 pm
by GWarner
Maybe using the equal sign for two different purposes isn't such a good idea.

C and PHP solves the problem by using "=" as the assignment operator and "==" as the comparison operator.
Pascal solves the problem by using := as the assignment operator and = as the comparison operator.

Both remove the ambiguity about what the = is supposed to do.

Re: PureBasic 4.50 is out !

Posted: Sat Jun 26, 2010 12:34 pm
by nase09
GWarner wrote:Maybe using the equal sign for two different purposes isn't such a good idea.
C and PHP solves the problem by using "=" as the assignment operator and "==" as the comparison operator.
Pascal solves the problem by using := as the assignment operator and = as the comparison operator.
Both remove the ambiguity about what the = is supposed to do.
but Purebasic is Basic, so it would be a bad idea to use e.g. Pascal or C syntax..

Re: PureBasic 4.50 is out !

Posted: Sat Jun 26, 2010 12:36 pm
by Mr Coder
nase09 wrote:but Purebasic is Basic, so it would be a bad idea to use e.g. Pascal or C syntax..
So true! Too many people here forget that, and want PureBasic to be something other than Basic. :roll:

Re: PureBasic 4.50 is out !

Posted: Sat Jun 26, 2010 1:52 pm
by mk-soft
a small assistance without a warranty for future versions

Code: Select all

Macro BOOL(assert)
  ((assert) Or #False)
EndMacro

Procedure foo1(a,b)
  
  ProcedureReturn bool(a > b)
  
EndProcedure

Procedure foo2(a,b)
  
  ProcedureReturn bool(a < b)
  
EndProcedure

c = foo1(a,b)
Debug c

c = foo2(a,b)
Debug c
Show asm output :wink:

P.S. Also computations can be implemented

Code: Select all

Macro BOOL(assert)
  ((assert) Or #False)
EndMacro

For i = 1 To 10
  c = i * 10 * bool(i >= 5)
  Debug c
Next

Re: PureBasic 4.50 is out !

Posted: Sat Jun 26, 2010 3:08 pm
by GWarner
I know that PureBasic is BASIC, nor am I suggesting that it should use C or Pascal syntax, if you had really read my message you would have seen that.

I'm just suggesting that using the same operator for two completely different purposes isn't such a good idea. The designers of C and Pascal apparently didn't think it was a good idea either.

Since this is dragging this thread way off topic, I'll stop here.

Re: PureBasic 4.50 is out !

Posted: Wed Jul 14, 2010 5:18 pm
by Frarth
I entirely agree with blueznl. People migrating from (Visual) BASIC are VERY used to boolean expressions as return values or as part of formulas.

With PureBasic working with boolean expressions is still very confusing. For example, this works:

Code: Select all

Procedure.i LeapYear(Year.i)
  ;returns:
  ;  - True (1) If the given year is a leapyear
  ;  - False (0) if the given year is not a leapyear
  ProcedureReturn ((Year % 4) = 0) And ((Year % 100) <> 0) Or ((Year % 400) = 0)
EndProcedure

Debug LeapYear(2008)
Debug LeapYear(2009)
Yet, this simple one does not work:

Code: Select all

Procedure Equal(a.i, b.i)
  ProcedureReturn (a = b)
EndProcedure

Debug Equal(1, 2) ;should return 0 (#False), but returns 2 instead.
IMHO people new to PureBasic should be thoroughly informed about this!

Re: PureBasic 4.50 is out !

Posted: Wed Jul 14, 2010 6:08 pm
by Thorium
I read somewhere on the forum that boolean expressions are planed. So we will see how they solve the = issue. ^^

@Frarth: It's not confusing, because they are not supported outsite of if statements. So you should not use them in formulas at all. It's planed and i hope it will come, but it's not just yet supported.

Anyway a compiler error message would be nice.