Navigation

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

    A Fuze update will probably need to break my code

    Comments & Feedback
    1
    2
    357
    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.
    • PB____
      PB____ last edited by

      I was under the impression that Fuze assigned by value, not by reference. And I have build under this assumption.

      Now I discovered by reading other people's code that this behavior is not consistent. For example in Jump a Face by Gothon, there is the following function that works:

      Function SwapEle(Arr, I, J) // Swap array elements
          var Tmp = Arr[I]
          Arr[i] = Arr[J]
          Arr[J] = Tmp
      Return VOID
      

      This implementation fully relies on the fact that SwapEle gets the array by reference, so that any changes made to it, will apply to all variables pointing to the same reference.

      Unfortunately with my game 2048 I initially encountered different behavior, so I've build on that. To illustrate the difference:

      function println(v) print(v, "\n") return void
      nested = [[1,2,3]]
      println(nested[0]) //[ 1, 2, 3 ]
      SwapEle(nested[0], 1, 2)
      println(nested[0])  //[ 1, 2, 3 ]
      ref = nested[0]
      nested[0][1] = 4
      println(ref)  //[ 1, 2, 3 ]
      printlin(nested[0])  //[ 1, 4, 3 ]
      ref2 = ref
      ref[2] = 5
      println(ref)  //[ 1, 2, 4 ]
      println(ref2)  //[ 1, 2, 4 ]
      

      I know there is awareness of this bug, but I just wanted to give the feedback that my game 2048 (at least in it's current implementation) will break when this gets fixed in an update. And I just wanted to let you know that I'm 100% fine with that, so I hope that should not be concern with any future update.

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

        Small update on this: I was talking about 2048 here. .
        I think/hope my solitaire game should work with either decision on how the code should behave... At least I've build it with this uncertainty in mind.

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