Announcement

Collapse
No announcement yet.

[CLOSED] [#990] Int.div suppress attribute

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    [CLOSED] [#990] Int.div suppress attribute

    Hello, is it possible to make a attribute for class/namespace/method that will disable default behaviour when doing int division ?

    when i do
    int k = 7;
    double a = 5 / k;
    as result i get:
    var k = 7;
    var a = Bridge.Int.div(5, k);
    which is really annoying, and im hunting some wired errors, i already have my mind setup to work in javascript, and i dont want to mark all my numbers as double/dynamic, but i want strong type match. In javascript im used to know that if i do int division i need to use floor. It make no sense if you are working in "C#" world, thats why such an attribute would be a nice feature
    Last edited by Daniil; 2016-02-22 @ 04:34 PM.

    #2
    Thanks for suggestion. We will discuss it.
    At this moment you can try the following workaround (looks not nice but you can try to use it)
    http://live.bridge.net/#01224ff162b8fc18b236

    Comment


      #3
      Thanks for suggestion, currently i use dynamic or double for workaround, and in this case i would like to avoid extra code, thats why i proposed to add this support on compiler level. Thanks for proposed solution and possible discussion!

      Comment


        #4
        We discussed at our Monday standup. This functionality is related to some other ideas we had. We need more time to think about how to approach them all in a manageable way.

        Unfortunately we do not have a timeline for implementation, but we'll try and come up with something soon.

        Comment


          #5
          Great, thanks for considering this feature.

          Comment


            #6
            Created an Issue:
            https://github.com/bridgedotnet/Bridge/issues/990

            Comment


              #7
              Great thanks!

              Comment


                #8
                Integer division will be disabled automatically for OverflowMode = Javascript (you can still use integer division for project with OverflowMode = Javascript, just wrap by checked/unchecked statements)

                Comment


                  #9
                  Great, that is verry helpful, its really nice that it still could be used under checked statement

                  Comment


                    #10
                    Please see the new Integer Rule.

                    https://github.com/bridgedotnet/Brid...eference#rules

                    Rules can also be configured project-wide by setting the rules in your projects bridge.json file.

                    https://github.com/bridgedotnet/Brid...guration#rules

                    The following sample demonstrates adding the [Rules] attribute to a Method.

                    public class Program
                    {    
                        [Rules(Integer = IntegerRule.Plain)]
                        public static void DoSomething()
                        {
                            int k = 7;
                            double a = 5 / k;
                        }
                    }
                    Before

                    var k = 7;
                    var a = (Bridge.Int.div(5, k)) | 0;
                    After

                    var k = 7;
                    var a = 5 / k;

                    Comment

                    Working...
                    X