Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    Suggestion add #define

    Comments & Feedback
    2
    4
    204
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • E
      EvanTropFun last edited by

      In C or C++ there is a so cool things !
      The #define to attribute a word on an instruction

      Please add this for an update !

      1 Reply Last reply Reply Quote 0
      • PB____
        PB____ last edited by

        I have so many questions!
        What does it do? Why do you think it's cool?! And why would like like to have it in Fuze???

        1 Reply Last reply Reply Quote 1
        • E
          EvanTropFun last edited by EvanTropFun

          Ok i will do an exemple, if you have an array with sprite data, you update it in a for loop, you that :

          for i = 0 to len(object) loop
           object[i].x += 1
           object[i].y = cos(object[i].x)
           object[i].size = object[i].x * object[i].y
          ...
          repeat
          

          Its long to write object[i].x ...object[i].y ...

          So with #define you can attribute word on a piece of code !
          exemple :

          #define Obx object[i].x
          #define Oby object[i].y
          #define Obsize object[i].size
          #define Lobj len(object)
          
          for i = 0 to Lobj loop
           Obx += 1
           Oby = cos(Obx)
           Obsize = Obx*Oby
          repeat
          

          it's a real time saver

          PB____ 1 Reply Last reply Reply Quote 0
          • PB____
            PB____ @EvanTropFun last edited by

            The problem I see with that is, if you only look at the for loop (without the define statements), then it looks like Lobj, Obx etc. are simple variables. There is no way to tell what any code does anymore, unless the code editor has good color coding and you're not color blind.

            So it might make writing code quicker. But it will make reading code more difficult.

            So in my opinion, a language change that would make your example more efficient would rather be a foreach iterator. Not that I'm expecting anything like that in Fuze, but it could look something like this:

            foreach var o in objects loop
                o.x += 1
                o.y = cos(o.x)
                o.size = o.x * o.y
            repeat 
            

            By such a change, it's still clear from looking at the code, what is supposed to happen, and you don't need to think about the type of collection you're iterating over. In case of Fuze, there are only arrays, so in my opinion, a change like this doesn't need a high priority :)

            1 Reply Last reply Reply Quote 1
            • First post
              Last post