View Full Version : Signs of life out there!
ReneMiner
30-04-2014, 18:05
You won't believe it, but it's true!
For me tB is more than just the current being. It's a universe and without any movement evolution is on cessation!
Lately I almost thought I discovered life out there.
If only that signal would re-appear...at least a small beep...
Scientists say it came from near Milano
ErosOlmi
30-04-2014, 21:39
:onthequiet:
ReneMiner
30-04-2014, 22:03
:dance1::yahoo::party:...
must have been some fata morgana
:(
ReneMiner
07-05-2014, 07:22
Here you can find the places where all NOT work-in-progress software lie:
https://www.google.it/search?hl=it&q=cemetery&bav=on.2,or.r_cp.r_qf.&bvm=bv.45512109,d.ZWU&biw=1918&bih=1019&um=1&ie=UTF-8&tbm=isch&source=og&sa=N&tab=wi&ei=J3VyUeHQJMaVtAbarIGgCA#um=1&hl=it&tbm=isch&sa=1&q=cemetery+&oq=cemetery+&gs_l=img.3..0l5j0i24l5.78999.80926.6.81251.5.5.0.0.0.0.112.495.3j2.5.0...0.0...1c.1.9.img.pmOHZlw_W4E&bav=on.2,or.r_cp.r_qf.&bvm=bv.45512109,d.Yms&fp=2b5f48d61f20175&biw=1918&bih=1019
In memory of ...
Petr Schreiber
07-05-2014, 19:33
There can be fun at the cementery - do not underestimate the power of squirrels! ;)
Petr
ReneMiner
08-05-2014, 00:14
I'm just so sad that I can not continue to develop my current project- and I fear the worst (= have to dump or shelve it like a dozen other projects). But its like I can do the half of it in a clean way and the other half in an "unclean" way. It hurts to do it the unclean way because I want to be an outstanding shining example- but.. :cray: I want it to be alive and useful... :unguee:... I'm already looking out for alternative languages but it would make me sad to drop tB
Petr Schreiber
08-05-2014, 00:16
Which features are the most critical for you at the moment, Rene?
Petr
ReneMiner
08-05-2014, 00:19
Simply the calling of a type function at a pointed position instead of a variables position, look there-> look here
(http://www.thinbasic.com/community/project.php?issueid=459)
ErosOlmi
11-05-2014, 11:22
Hi Rene,
sorry for the delay but I had few problems.
I started to look into your request.
The method you suggested here (http://www.thinbasic.com/community/project.php?issueid=459) is very clever, you mainly have discovered alone how thinBasic internally works.
As you already suggested, there is a gap because you need to indicate inside a method (UDT function) a global variable ("BY" global variable) and this is not good:
Function t_myType.AddUp(Optional ByVal C As Long) As Long
' have to add this to every type-function currently:
If By.pData Then
' # # # # # # # # # # # # # # # # # # # # # # # #
Local Me Like By.sType At By.pData ' << << <<
' # # # # # # # # # # # # # # # # # # # # # # # #
By.pData = 0
EndIf
'- - - - - - - - -
' now the function:
Return Me.A + Me.B + C
End Function
In general what you asked is something I can develop but I need to find a clever syntax.
ME pseudo variable is the main problem. It is automatically created/allocated by thinBasic engine as a pointer to the calling UDT variable when a method (UDT function) is invoked and this is possible only because thinBasic knows the UDT variable been used to invoke the method.
I will let you know.
Eros
ReneMiner
11-05-2014, 12:36
Hi Eros, nice to hear from you again :)
The Like-Way for the "Dim Me ...At" was just an abstract way but into the other direction :
the functions name is (until dot) equal to the types name... the function is anyway part of the type.
if the function is really part of an udt and there were some internal ME-structure for any type-function - how can one use that anyway existing pattern on some pointer instead of a variable?
The problem of the logical way ( call a function which creates the overlay as t_Type locally and then calls the t_Type.sFunction ) were, that this delegating-function could not handle over the passed paramaters nor pass back the result, neither could compose the type-functions name with that local overlay-variables name, see illustration below.
#Pseudo-Code
'assume a delegate-call-function
Function Delegate(Byval pData as Dword, Byval sType as String, Byval sFunction as String,
[ ByRef original methods parameters ?] ) ' As ???
Local data Like sType At pData
Function = data. & sFunction( original methods parameters ) '<< this impossible twice...
End Function
' now if I would call some type-function, lets say "AddUp" and has 3 parameters (1,2,3)
Delegate pData, sType, "AddUp" (1,2,3) To Result '?
how can one hand-over the original type-functions-parameters or compose the function name?
ReneMiner
16-05-2014, 10:01
still thinking about syntax - today I come up with this - no call-keyword:
[Result =] Like "myType" At pData, "[.]myFunction" ([parameters])
the thought behind:
Like (without DIM-keyword) could create an absolute temporary variable that immediately gets destroyed again after the codeline was proceeded. The main-problem I have currently is, if using "DIM|LOCAL varname..." it's impossible to change type of varname again.
If there were only some "pseudo-variable" whithout any name the function containing this call could not "remember" that variable - so no multiple-Dim-Error...
Petr Schreiber
17-05-2014, 10:27
Hi Rene,
I love the proposed functionality, but the syntax diverges a bit from BASIC approach, that is, to make the code human readable.
What about:
[Result =] Call "[.]functionName" ([params]) Using pData As|Like Type|"Type"
Examples:
sText = Call ToString() Using pVector As Vector3D
sText = Call ToString() Using pVector Like "Vector3D"
It is more like english sentence, still brief enough to separate the functional blocks by context giving keywords...
Petr
ReneMiner
17-05-2014, 11:19
I thought into that direction too already, but I thought call would only work the "Call ... To Result"-way but not like "Result = Call..." - but if that were possible- I'd be happeeeeh.
Really I don't care much about the final syntax - it's more about the functionality and as Eros already ascertained not to need some global variables therefore.
I was hoping there would be some "default-layover" to each and every type created during the type-definition that would be placed on the calling variables position if a type-function ("Method") gets called through a variable of that type and since the call on a pointer would not be a call from a variable, Me is not dimensioned within the method anyway, so there could be some additional Call-Keyword that indeed just sets the Pointer where to find Me which would be the simplest way.
Call_At pData, "myType" ,|& "[.]myMethod"[([methods_paramaters])] [To Result]
-also syntax were easy, similar/close to Call_IfExists
ReneMiner
20-05-2014, 08:22
perhaps syntax like that:
Type t_example
X(123) as Byte
fun as Function
End Type
Function t_example.fun()
' whatever
End Function
Dword pData = Heap_Alloc(SizeOf t_example)
[Result =] ByRef [Like] "t_example" At pData, "[.]fun"()
Petr Schreiber
20-05-2014, 21:40
It would be ideal to have thinBasic SDK function allowing to do this, the syntax for ThinBASIC language itself could be arranged later and customized by module creators.
Something like:
thinBasic_GetTypeHandle( ByVal sType As String ) As Dword ' -- For decoding type from string
thinBasic_GetFunctionHandle( ByVal sFunction As String ) As Dword ' -- For decoding function from string
TYPE thinBasic_Param
valuePassingType As Long ' -- Byval/Byref
valueType As Long ' -- TypeOf thing, returned by thinBasic_GetTypeHandle
valuePointer As DWord ' -- Pointer to actual data
END TYPE
thinBasic_FunctionCallUDT ( ByRef variable As Any, functionHandle As DWord, params() As thinBasic_Param ) As DWord ' -- Allows using UDT variable directly or via ByVal pointer override, params passed as array of them. Returns pointer to return value
Petr
ReneMiner
21-05-2014, 09:59
You already seem to have some usage for this in mind and I think it would be another big step to dynamic different subtypes which is probably a very rare feature - most basic dialects i know allow either fixed size subtypes only, some not even dynamic subarrays and I don't know a single programming language that would allow individually different subtypes to elements of the same maintype without having to code the memory-management by oneself.
All this could be done easily if we had this feature (best would be together with the Item-Type & some EnumType-Function built-in- I hope you remember*) and I pray to the Lords of Basic that Eros will find the time to implement this and also to fix bundle-utility asap, so we have an applicable tB-version this summer available.
*Item-Type: enables to append 1-dimensional arrays or single elements of any type to anything that can store 2 Dwords|1 Quad. Attached Unit contains the basic functions only.
I think it's about time that thinCore itself gets its first functional types built-in anyway
John Spikowski
21-05-2014, 17:57
I pray to the Lords of Basic that Eros will find the time to implement this
It seems Eros has been pretty busy with real life and thinBasic isn't on a fast-trac with it's ongoing development. Maybe it's time for Eros to open the development door to a few developers like yourself, Petr and Charles. As I understand it thinBasic is a labor of love and therefore I see no reason not to spread the joy to others committed to making thinBasic a great BASIC language.
Petr Schreiber
21-05-2014, 23:31
Rene,
nothing worse than false hope, but during my way home from work I got an idea for hack.
I will try it during weekend - if I forget, feel free to remind me I have a homework to do!
Petr
ReneMiner
23-05-2014, 08:26
Hack? Nosy... what kind of? Is it to poke the pointer into some "constant" variable to kind of "protect" the global?
Petr Schreiber
24-05-2014, 11:04
Hi Rene,
I thought I will manage to implement the functionality for you, but I succeeded only partially.
If you download attachement, you will be able to do this:
Uses "MeHack"
' ---
Type MyType
a As Single
b As Long
func As Function
End Type
Function MyType.func()
Dim data As MyType At IIf(VARIABLE_Exists(Me), VarPtr(Me), CBHNDL)
MsgBox 0, "MyData:" + $CRLF + data.a + $CRLF + data.b
End Function
' ---
Dim data As MyType
data.a = 1.2
data.b = 3
DWord dataPtr = VarPtr(data)
MeHack_CallFunction(dataPtr, "MyType.func")
So I basically force CBHNDL to hold data pointer for ya :D
The package includes:
module source code for PB10
compiled module
test script
I think I would be able to hack together function allowing to do this + pass parameters somehow. Sadly the function allowing to pass parameters doesn't allow to pass CBHNDL as of now, so it is not possible to do.
To achieve your requirement, it would be needed to expand thinBasic_FunctionCall_ByPtr from SDK with pointer to ME. That should do the trick.
Petr
ReneMiner
24-05-2014, 11:50
we had this already: variable_exists gives correct result only on first call. If Me was dimensioned once then Variable_Exists results true, no matter if defined in current call or in a call before. So this works as long as the function gets called the MeHack_CallFunction-way only.
Also I can not see any parameters that could be passed to myType.func() in the example - so the approach I took here (http://www.thinbasic.com/community/project.php?issueid=459#note2723) was more advanced already.
It still requires to insert the same part of code (If something then Dim ..As ... At..) to each and every type-function while the type is "known" anyway to the function since it is its "parent" and also to find as String in the functions name before the dot.
If the call is not made from a variable as usual, ME is not dimensioned inside the function anyway -
There are two ways to call a type-function thinkeable:
-one possibility is to call a special Delegate-Function that would create a local overlay at pData and then call the function on it the regular call-a-type-function through a variable-way, but the problems would be to compose the functions name for the final call from a local variables name and from a string that was passed to delegate. The other problem would be to hand-over the parameters from our actual call to "Delegate" to the finally called Type-function. Both can not be done from tB-scripts currently.
-second possibility would be, to tell type-functions WHERE to find Me -which is probably already the case- and optional TypeOf(Me) if the variables pattern can not be copied from the calling variable. It could as well be taken from the functions name or from the internal stored type-definition where that
Alias STATIC As "type.function Ptr"
is a part of - means a function of a type is in reality just a static variable containing the functions pointer, common to all elements and/or variables of that type
- but all that has to be done very deep inside core...
Petr Schreiber
24-05-2014, 13:49
Hi Rene,
well, you are right it does not solve problem (this is what I write in my post too :)), but I managed to identify possible concrete point for improvement - addition of new (optional) parameter to SDK function.
To make it work like we need, one change needs to be made to thinBasic_FunctionCall_ByPtr - optional ME pointer.
This would provide low level backend, which could be used by syntactic sugar in language itself.
No need for typeOf in this case - thinBasic engine already knows the type for <type>.<functionName> functions.
Petr
ReneMiner
07-06-2014, 11:27
still hoping for a miracle
Petr Schreiber
07-06-2014, 14:12
Hi Rene,
I was looking into this, but I can't do much about it at the moment - my knowledge in this area is limited.
In case I run into case like this (waiting for feature xy), I tend to create high level layer which will have not nice but working implementation inside, and will replace it with proper functionality once available.
Petr