Results 1 to 17 of 17

Thread: [RESOLVED] Circular Reference in UDT

  1. #1

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,195

    Resolved [RESOLVED] Circular Reference in UDT

    I'm wondering why we can't have a circular reference in a UDT, but we can for a Class.

    If I put my UDT in a TypeLib, can I have a circular reference?

    Or, is there a way to "trick" the compiler and force it through? Probably not.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  2. #2
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,119

    Re: Circular Reference in UDT

    You can:

    Name:  UDT circular reference.jpg
Views: 119
Size:  17.7 KB

    BTW: you posted in the Codebank.

  3. #3

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,195

    Re: Circular Reference in UDT

    Quote Originally Posted by Eduardo- View Post
    BTW: you posted in the Codebank.
    Ahhh, I'll notify moderators.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  4. #4

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,195

    Re: Circular Reference in UDT

    Quote Originally Posted by Eduardo- View Post
    You can:

    Name:  UDT circular reference.jpg
Views: 119
Size:  17.7 KB
    Eduardo, you didn't provide an example where it works. In your example, if you click "OK" (or, in your case, "Aceptar"), you just go to the line with the syntax error. It won't execute.

    I must admit, you had me excited for a moment.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  5. #5
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,908

    Re: Circular Reference in UDT

    You can for a class because under the hood it's just storing a pointer.

    A UDT with only basic types is flat, so it would attempt to expand it as
    Code:
    Private Type Testing
       aaa As String
       bbb As String
       ccc.aaa As String
       ccc.bbb As String
       ccc.ccc.aaa As String
       ccc.ccc.bbb As String
       ccc.ccc.ccc.aaa As String
       ... on and on to infinity
    But when you have a class, it's just a Long set to 0 until you instantiate a new instance.

  6. #6
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,119

    Re: Circular Reference in UDT

    Quote Originally Posted by Elroy View Post
    Eduardo, you didn't provide an example where it works. In your example, if you click "OK" (or, in your case, "Aceptar"), you just go to the line with the syntax error. It won't execute.

    I must admit, you had me excited for a moment.
    I misunderstood what you said. I understood that you were saying that the circular reference error did not happen with UDTs.

    Why do you need to have a circular reference in an UDT?

    You can't because it would generate an infinite UDT in size.

  7. #7

  8. #8
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,908

    Re: Circular Reference in UDT

    In kernel mode, the API has a lot of linked lists..

    Code:
    Public Type LIST_ENTRY
        Flink As LongPtr (*LIST_ENTRY)
        Blink As LongPtr (*LIST_ENTRY)
    End Type
    
    typedef struct _LIST_ENTRY {
      struct _LIST_ENTRY *Flink;
      struct _LIST_ENTRY *Blink;
    } LIST_ENTRY,

  9. #9

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,195

    Re: Circular Reference in UDT

    Quote Originally Posted by VanGoghGaming View Post
    You could store a pointer to the original UDT instead if that helps...
    Actually, that's a very good idea.

    -------------

    And yeah, the more I think about it, it makes sense that we can't "nest" ourselves, as it would create an infinite "dot" reference. Makes sense.

    -------------

    I'll get this thing running, and then possibly store pointers in the UDT rather than class references.

    -------------

    I soooo wish we had "inline" classes like more modern languages. My whole idea is to keep this little project all in one module, which is sooo hard to do when you need classes to do things.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  10. #10
    Addicted Member
    Join Date
    May 2012
    Location
    42.787034,-81.176367
    Posts
    136

    Re: Circular Reference in UDT

    Quote Originally Posted by Elroy View Post
    I soooo wish we had "inline" classes like more modern languages. My whole idea is to keep this little project all in one module, which is sooo hard to do when you need classes to do things.
    Would creating a class for instantiation at runtime be a solution?

    https://www.vbforums.com/showthread....=1#post5334801

    Joe

  11. #11
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,119

    Re: Circular Reference in UDT

    Quote Originally Posted by Elroy View Post
    I soooo wish we had "inline" classes like more modern languages. My whole idea is to keep this little project all in one module, which is sooo hard to do when you need classes to do things.
    Use twinBASIC

  12. #12
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    1,539

    Question Re: [RESOLVED] Circular Reference in UDT

    What can you do with an inline class that you can't do with UDTs and a normal BAS function?

    You could even go so far as to enhance UDTs into light-weight objects and even attach "methods" to UDTs and call them with DispCallFunc to avoid implementing IDispatch...

  13. #13
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,908

    Re: [RESOLVED] Circular Reference in UDT

    I know Elroy seems to be a kick lately of "How can I do this thing that twinBASIC makes trivially easy in VB6 where it's much harder or impossible?'

    Standard DLLs, Unicode in the editor, and now inline classes... Will tomorrow be class constructors, having one method implement multiple interfaces for it, targeting modern CPU instruction sets, overriding the entry point....?



    (Sorry I know I mention it a lot, just beyond stoked about a true successor like if VB6 had been continued these 25 years)

  14. #14

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,195

    Re: [RESOLVED] Circular Reference in UDT

    Quote Originally Posted by fafalone View Post
    I know Elroy seems to be a kick lately of "How can I do this thing that twinBASIC makes trivially easy in VB6 where it's much harder or impossible?'
    hahaha, I really think very little about tB, and haven't even taken a serious look at it nor download it (yet). I guess my mind just runs the same way that the developer(s) of twinBasic does/do. I've just worked with VB6 for sooooo many years (truly since the beginning, and before), that I just know and trust it soooo much. It's really hard to switch.

    If another major project ever came my way (which I doubt it will, and if it did, I'd probably turn it down), I'd almost certainly head toward C++ (or Python, if speed wasn't a big issue).

    ------------

    If I'm honest about it, there are really two reasons I stay involved: 1) I truly believe that doing intellectual tasks keeps my mind healthy, and 2) I just really enjoy it. With those in mind, there's just really not a big pull for me to switch over to tB.

    ------------------

    Ohhh, I'll mention this for fun too. My daughter is in a Human Factors PhD program, and is required to write programs for various things. They recommend Python, but they're really not terribly concerned as to which language(s) she uses. I've taught her VB6, and she absolutely loves it.

    Several of her professors tell her that Python is trivial to use, but they're lying to her. Python is ok, but it's far from a trivial language to use. Variable scoping in that language is constantly giving me a headache. I will agree that it's got very nice features that VB6 doesn't have (inline classes, nested classes, nested functions, true inheritance, a wildly rich library of utilities, etc.).

    For those who wonder what Human Factors is, a short definition would be: The scientific examination of how humans interface with technology (and how it can be improved).
    Last edited by Elroy; Apr 23rd, 2024 at 06:58 PM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  15. #15
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,908

    Re: [RESOLVED] Circular Reference in UDT

    I've been using VB6 since it came out too; but of course even when it came out I was wanting to exceed its limitations. I wanted the VB6 language to do more; not switch to a new language; my heart broke along with so many others when Microsoft told us all 'GFY, there's no VB7, you'll use .NET, end of story'. It was never about staying on VB6 forever; VB7, VB8, continuing to evolve the *existing* language had been the hope. So when that finally came to be a real possibility, the same language as VB1-6 with a bunch more features, it's what I wanted for 25 years.

    You don't need to fear running out of puzzles in it though lol... like it can make a standard DLL, but could we hack it to make a DLL ourselves from the entry point with no help from automatic code? We had some fun a few weeks back seeing if we could coax it into letting us create an exe from scratch too, see how small it can be made. The answer? 4KB; and only that large due it padding out to that size minimum (VB6 you have to count the runtime-- need to strip that out to compare). Not even out of beta, we're already pushing its limits. The new features *expand* the intellectual tasks... believe me I understand, after all, these days I'm just a hobbyist doing it for fun like you. New language features and 64bit open new more frontiers than they close, and there's still plenty of need for hacking around language limits.

  16. #16
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,262

    Re: [RESOLVED] Circular Reference in UDT

    Quote Originally Posted by Elroy View Post
    Human Factors is, a short definition would be: The scientific examination of how humans interface with technology (and how it can be improved).
    She should speak to me... - https://www.deviantart.com/yereverluvinuncleber/gallery

    Take Faf's advice and at least give TB64 a try, I will make that leap myself soon.
    https://github.com/yereverluvinunclebert

    Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.

    By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

  17. #17

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,195

    Re: [RESOLVED] Circular Reference in UDT

    @Fafalone & UncleBer: Yeah, I'll definitely take a look at tB fairly soon. It's just another one of those projects that seems like it has a fairly steep learning curve, for which I have to get into the right "head space" to tackle.

    I'm still getting fully up to speed with Python (as my daughter is also learning it, and it's a wonderful vehicle for me to stay connected with her). But, I will eventually take a serious look at tB. Other than talking about it with you guys (which I do value), and maybe some "quick utility programs", I'm not sure I (personally) would do much more with it. Regarding VB6, I've got my daughter, one of my four sons, and people continuing development of my primary application with which I interact.

    In many ways, the VB6 IDE truly is an amazing development tool. For someone who has a "head for programming", (and after getting the IDE installed), I can get them up and running, developing a program with a fully functional GUI, compiling a portable EXE, and running it anywhere, all within about 30 minutes for a simple program. I know of no other programming language for which that's true. Maybe tB? But IDK yet.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

Posting Permissions

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



Click Here to Expand Forum to Full Width