GLBasic forum

Main forum => Bug Reports => Topic started by: bigsofty on 2011-Jun-30

Title: given: Expressionl wants...
Post by: bigsofty on 2011-Jun-30
I can't get the following to work...

Code (glbasic) Select
GLOBAL a AS TVec2
GLOBAL b AS TVec2

testType(a.vAdd(b))

FUNCTION testType: v AS TVec2
ENDFUNCTION


Code (glbasic) Select
TYPE TVec2 // Mini vector example

x#
y#

FUNCTION vAdd AS TVec2: b AS TVec2
LOCAL a AS TVec2
a.x = self.x + b.x
a.y = self.y + b.y
RETURN a
ENDFUNCTION
ENDTYPE


Creates the following error...
Code (glbasic) Select

*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.7.917 SN:114ddfeb - 3D, NET

  given: Expression
  wants: TVec2
"test2.gbas"(4) error : wrong argument type : testType, arg no: 1


Now I understand the error but I don't really understand why I cant use a function as a parameter, when that function returns a type that that parameter wants?

I can make it a separate line but this would drastically increase the size of my code, creating unneeded vars for each param and well it plain should not be doing this IMHO.  :blink:
Title: Re: given: Expressionl wants...
Post by: Kitty Hello on 2011-Jun-30
uh-oh. Now that's one of the situations where my GPC really must know the result of an expression (function call or whatever), which it does not.

I can try to fix that, but it will take a lot of work. Don't expect that by tomorrow. So sorry, really. :(
Title: Re: given: Expressionl wants...
Post by: bigsofty on 2011-Jun-30
No problem Gernot, I have a talent for finding you work I am afraid!  ;/

I don't know some sort of casting help in the syntax, "TVec2(myfunc(foo))"? Ideally though, the GPC should know if a function is being used as a parameter, then to do this automatically I suppose.

In the mean time, I'll pause development of this lib for now.

P.S. Ahem, now if I could oveload some operators...  =D

Edit: Gave it a good hour trying to figure out various ways to do a vector lib without having every seperate vector operation on a separate line, no go. I don't think this can be done, efficiently in GLB at all unfortunately.