• Welcome to Jose's Read Only Forum 2023.
 

Wishlist for a new PB Version?

Started by Theo Gottwald, January 23, 2012, 08:21:24 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Theo Gottwald

While PB 10 is my absolute NR.1 programming tool, there are always some wishes open for a new version.
So why not start a new wishlist and/or opinion thread?  So here is a start from me.

PB 10 did a lot about COM Objects and UNICODE which was a milestone in the right direction.
The new PB-Editor is leapyears ahead of older versions.  And i believe that it got really good finally.

However the principles that all builtin commands are "as fast as possible" have come a little bit under the wheels,
when we talk about PowerCollections, LinkedLIsts, Stack, Que and such.

Their problem with actual version for me is that they are (very versatile) based on VARIANTS and on UNICODE (Ex-VB 6 programmers will love it that way),.
Which definitely makes them slower then dedicated datatypes. Because the conversion need time on any acess..

Stan Durham shows the right way with his high-speed datatypes and Arrays. At least for my programming style.

This would also be a nice completion of the PB ARRAY-Functions:
PB-Forum Stan's Array-Macros

We have now PowerArrays, is somebody here using them?
They also look like they are slower then the native PB Arrays.

Some Additions for the native PB-Arrays like Stans Macros  above ( the Redimming can be optimized), would be my idea of an improvement.

These datatytpe are less versatile but much faster. For me, new VARIANT Objects are not what i would need.
I prefer very fast low-lever things, which i can use to build whatever i need.

Then i would wish the new HSTRING datatype (best in a PB x64). And some expansions in MACRO abiilities.
And a bit more flexibility with the META-Statements #IF #ENDIF (higher possible nesting depth).

Also i believe that there are minor adjustments in the already fine Dead Code Removal possible.
When it comes to static variables.

And i beliefe that the Editor should be further imporoved. He's already a fine tool, but is also the place where the distance to competitors is still the largest.

Thats my PB 11 wishlist for now. Now what your opinion.

José Roca

Quote
We have now PowerArrays, is somebody here using them?

Yes. They are safe arrays, and like collections, are meant to be used with COM, not as substitutes of normal arrays. Safe arrays are used to pass/receive information to/from Automation languages that don't have the slightest idea of what a PB normal array is, and collections are meant to pass or receive several object references at once, not to build an indexed array of the words used in the bible. Use the tools correctly and don't expect a car to fly. If you need to fly, use a plane.

Peter Weis

#2
Hello Theo
would wish me things like direct assignment of variables!

    Local x as integer = 7
    dim x as long = 5


in addition ASM blocks

Asm
    Mov ax, 2
    Mov bx, 3
end asm

to me breaks in however still much! But is enough only once!

Greet Peter


José Roca


in addition ASM blocks


You already have


PREFIX "ASM"
   Mov ax, 2
   Mov bx, 3
END PREFIX


Nobody reads the help file?

Peter Weis

#4
Hello Jose,

I does not need thousand new instructions, which I will never take ago in my life! It may be already safe these instructions is safe, and the life to facilitate! Only one loses of it the overview! It would be whom for example power basic the pointer type not as DWORD to return beautifully would separate with the name then would give it also no problem hereby with transferred to 64 bits


type test1
    Var1 as integer
    Var2 as long
end to type

Function testxxx () as test1
    Local x as test1
    Function = x
end function



greetings Peter

José Roca

Quote
type test1
    Var1 as integer
    Var2 as long
end to type

Function testxxx () as test1
    Local x as test1
    Function = x
end function

Code like this would only work only with PB, and then you will complain that your DLL that has such function does not work with other compilers. It already happens with languages such C++, Delphi and GCC, and have to use structures passed by reference if they want to be compatible with other languages. Why? One makes the structure static and returns a pointer to it, but only if is more than 16 bytes long; otherwise, it returns the values into the stack; others use other ways, that are incompatible between them. PB can return an structure as the result of a method or property because COM sets the rules and a compiler that is COM compliant must follow them.

So, which of the three or more incompatible ways of returning an structure as a result of a function has to be implemented? And how to know which one is using the DLL written with another language? Or perhaps Mr. Zale has to use one that is incompatible with all the others?

If you need a workaroud for PB, here is one:


#COMPILE EXE
#DIM ALL

type test1
    Var1 as integer
    Var2 as long
end type

Function testxxx () as string
    Local x as test1
    x.Var1 = 123
    x.Var2 = 345
    Function = x
end function

FUNCTION PBMAIN

   LOCAL t AS test1
   TYPE SET t = testxxx
   ? STR$(t.Var1) & STR$(t.Var2)

END FUNCTION


Peter Weis

Hello Jose,
meant handing over byref! ," parses by ref" Und I was concerned about the dword! It is clear for me variable must on global Heab has to go! 

Example:


type test1
    Var1 as integer
    Var2 as long
    var3 as string * 20
end type

Global x as test

Function xyz() as dword
       x.Var1 = 10

       Function = varptr(x)   'parse by ref
End function



greetings Peter

José Roca

It looks like some people can't write anything without use globals. This example does not use any global variable.


#COMPILE EXE
#DIM ALL

type test
    Var1 as integer
    Var2 as long
    var3 as string * 20
end type

SUB xyz(BYREF x AS test)
   x.Var1 = 10
END SUB


FUNCTION PBMAIN

   LOCAL t AS test
   xyz(t)
   ? STR$(t.Var1)

END FUNCTION



José Roca

BTW have you tried my example on post #5? As strange as it looks, you can return an structure as the result of a function if you declare the result of a function AS STRING. And you can do it by simply using FUNCTION = <structure name>, without doing any conversion. Certainly, then you have to use TYPE SET to assign it to a new structure, but that's all.

Theo Gottwald

I always return structures from subs or functions, just have them BYREF as parameters.
About SafeArrays, you are of course right Jose. They are good for compatibility.
However i could imagine a addition for optional parameters:

SUB XYZ(OPT BYVAL A01=7 AS LONG)

or something liek that so i could give optional values a predefined value.

Charles Pegge


Developing default parameters for OxygenBasic I found it easier to adopt the C habit of placing the type before the parameter name. Then you get nice clean syntax for expressing default values:


function foo(string s="Hello", int *i=123)
print s+"   "+i
end function

'examples

foo
foo "Hi",1
foo s="Bye"
foo i=456
foo (i=789, s="Bye")



(note that 's' is passed Byval and i is passed Byref as indicated by '*i')

Charles

Edwin Knoppert

Local scope would nr #1 for me like:
Function Hello()

dim a as long

a = 100
{
    dim a as int
    a = 123
}

? a (=100)

--

Direct assignment of vars (as above mentioned)
dim a as long = 100

--

Removal of the naming conflicts, conflicts which seem to occure by hidden (PB) macro's or so..

--

Swap DDT for real SDK windows.

Peter Weis

Hello Jose,

I already read it! Are however function a fan! Me it goes however around larger structures which one no more than value returning can!
In all other respects the C, c++, knows and Freebasic also. Even with Visualbasic that can be done!

Greet Peter

Peter Weis

#13
Hello Theo,
that was my idea. ;D


SUB XYZ(OPT BYVAL A01=7 AS LONG)

I would continue to go however still another step!


Sub xyz(opt byval x as long = 7, opt byval y as long = 10, opt byval z as dword)

end sub


xyz y:=5, x:=Var         ' Call



or


xyz y=5, x=Var


;D
Greet Peter


Paul Elliott

Something does not make sense with the way you are using Optional parameters.

If you are making a call that has optional parameters  WHY would you want to pass a default
value? If you are passing a variable or a value then that is what is passed and therefore
that parameter HAS a value and is not missing/optional for this particular call.

It is the procedure itself which should be assigning default values to optional parameters that
are not passed. If the procedure has defined the optional parameters as BYVAL then the only
way to tell if it is absent for numeric variables is if it is equal 0  or for strings if it is 0 len.
If the procedure has defined the optional parameters as BYREF then it needs to check for a
valid variable address BEFORE using it.