Page 3 of 5 FirstFirst 12345 LastLast
Results 21 to 30 of 46

Thread: TypeOf- ideas

  1. #21
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Quote Originally Posted by ReneMiner View Post
    oops- I just saw I added a SetRGB in the Type-definition but there's no function - and no errror - even it's not an extended Type
    As I said, there is still no code that checks for errors, so at the moment mainly everything is possible.
    In particular, I'm thinking to add Abstract Types and Abstract Type Functions so having function declaration and not its definition will be possible, if Abstract.
    Last edited by ErosOlmi; 17-03-2014 at 18:15.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  2. #22
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Quote Originally Posted by ReneMiner View Post
    I tested a little... and came to the result it does not work as expected so I did not finish this to more functionality yet - has a couple of useless functions now, but shows what I was up to. Because no retrieving of type possible I just pass it as parameter on Create

    The types get recognized and used correctly - but just once per script execution. Calling twice the same sub with a different type to use will always dim the type again that was dim'ed the very first time... The example is a little longer, for try out/ see what I mean just exchange the order of the Test-call at end of script
    If you debug you will se that the problem is at:
    Function t_virtual_object.Create(ByVal sType As String, Optional ByVal lNum As Long) As DWord  Local Data Like "" & sType  '<<<<<<<<<<<<<<<<<<<<<<<<<<
    
    and at:
    Sub Test(what As t_virtual_object)  If HEAP_Size(what.pData) < 1 Then PrintL "Error- no data!": Exit Sub
      Local data(HEAP_Size(what.pData)/what.lSize) Like "" & what.sType At what.pData           '<<<<<<<<<<<<<<<<<<
    
    Like operator interpret the data type not like a data type but like a variable of a certain type.
    Add a
    "" &
    
    and it will get the string as string expression and create the real data type overlay.
    I will fix asap, not today, sorry.

    In any case there is a much bigger problem. ThinBASIC always try to optimize code execution. When it executes the following line the first time:
    PrintL data(1).GetProperties
    
    it stores inside internal optimization structures what is Data so the second time all the info are already there.
    But here we now have the possibility that Data is many different things in all different executions.
    I need to understand what to do in order not to store any info about Data without slowing down execution.

    Eros
    Last edited by ErosOlmi; 17-03-2014 at 18:17.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  3. #23
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,527
    Rep Power
    170
    maybe you don't need to change this if one could "delete manually" the for optimization stored data if needed only, some "clear current function-buffer" or a switch "don't create optimization-data" somewhere in the function - so it always assumes it would run for the first time or does not "remember data" on exit? Or some special use of New-Keyword here?
    Local New data Like "some udt"
    
    Last edited by ReneMiner; 17-03-2014 at 18:46.
    I think there are missing some Forum-sections as beta-testing and support

  4. #24
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Yes, something similar.
    Maybe I've already found a solution: I've added a special flag in internal variables that is ON when variable has been declared using the LIKE operator.
    In this case no code optimization will take place for that specific variable.

    Optimization is really "visible" when inside big loops. Mainly it stores some info instead of continuously reading from internal Hash Tables.

    Maybe I will be able to release a new version by this evening.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  5. #25
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Download again http://www.thinbasic.biz/projects/th...c_1.9.12.0.zip

    I think I've fixed the main issues.
    Last edited by ErosOlmi; 17-03-2014 at 19:37.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  6. #26
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,527
    Rep Power
    170
    I fear, just to check for the "LIKE" in dim-statement won't serve. Think of

    Dim data As Me
    I think there are missing some Forum-sections as beta-testing and support

  7. #27
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Quote Originally Posted by ErosOlmi View Post
    Rene,

    why just not using something like
    Local data As Me At VarPtr(Me)
    
    It is already working but IT HAS TO BE EXECUTED from inside the Function Type to which Me refers.
    Let me know.
    Exactly but only when executed from inside a Type Function
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  8. #28
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,527
    Rep Power
    170
    Quote Originally Posted by ErosOlmi View Post
    Exactly but only when executed from inside a Type Function
    to be precise: Me being another type than the initial one is (currently) only possible inside a function of a type that has been Extends'ed already by another existing type
    Last edited by ReneMiner; 17-03-2014 at 20:25.
    I think there are missing some Forum-sections as beta-testing and support

  9. #29
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Hehe,

    I check here at morning, I check here at night - and what I see? Implementation party !

    Cool stuff, I am testing it right now...


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  10. #30
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Suddenly, wild idea appears. TypeOf is traditionally not returning string, so why not create something like:
    GetType$(variableName)
    • takes any variable as input, and returns its type as string (I think it is internally stored in UCase, which is okay)
    • it would allow to store type... somehow, for later use with LIKE


    ThinBASIC has stored the names of all types inside, he can recognize type when parsing it from text... should be doable? What do you think, Eros?

    Example:
    Dim v As Long
    
    Dim s As String = GetType$(v) ' -- "s" will contain "LONG"
    
    Dim n Like s ' -- "n" will be of LONG datatype
    

    Petr

    P.S. Abstract functions/types sound interesting!
    Last edited by Petr Schreiber; 17-03-2014 at 21:26.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

Page 3 of 5 FirstFirst 12345 LastLast

Similar Threads

  1. OOP ideas
    By ErosOlmi in forum Suggestions/Ideas discussions
    Replies: 13
    Last Post: 26-08-2013, 20:26
  2. More Ideas
    By peter in forum Sources, Templates, Code Snippets, Tips and Tricks, Do you know ...
    Replies: 3
    Last Post: 27-10-2012, 14:47

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •