4

Another day, another possibly stupid idea for my language. Another one of those that's been floating in my head from the start, and I want to have it, but I'm not entirely sure about its implications...?

I mean... languages already have semantic feature like this, I'm just trying to extend the principle to not have any special cases, to be completely universal and have simple syntax.

Thoughts?

Comments
  • 0
    Not sure what you try to do, but know that => is actually creating a function.
    (https://docs.microsoft.com/en-us/...)

    What is the difference ? I guess none apart from the smaller code form.
  • 4
    Execute on get as in a getter is only syntactical sugar for a get function.

    And in my opinion its more about promise.

    A getter should not do actual business logic, only validation and formatting, and it should also not use dependency’s.

    Used with care a getter/setter or property depending on language indicates local access to the object at hand, for example so that different object types sharing an interface can store the actual data differently.

    But that also means it should be safe to use in loops.

    A function indicates more work and you should check before looping over large number of calls.

    I have abused setters snd getters in the past and learned the hard way that it ends badly, like a loop hitting the database repeatedly or similar.

    So its not just what looks good but the intention of the programmer and what its perceived as that is important.

    And that is not only a language problem but worth considering.
  • 1
    @Grumm @Voxera
    "not sure what you try to do"

    me neither in this case, i guess XD
    but yeah, it's just a function... you're both right. i guess i was hoping for it to be something more interesting/useful than just a shorthand syntax for one-line functions.
  • 0
    @Midnight-shcode for a pure function assignment, thats a lambda and quite useful as a concept.

    But lambdas are usually called with parentheses in most languages since without you pass the function it self instead of calling it.
  • 1
    Here's a different idea: reactive assignment vs imperative assignment vs active assignment

    Imperative: evaluated once and remembered
    Active: evaluated on access, essentially a function. Side effect free.
    Reactive: evaluated when any of the referenced values change, IF that value was accessed last time. Side effect free.

    The difference between active and reactive is one of performance, if you can guess which way your particular value acts then you can distribute expensive computations efficiently.
  • 1
    @lbfalvy reactive is how most functional languages manages performance, like f#, ocaml and haskel.

    Think its called memoization also.
  • 1
    Sorry, can't make a useful commitment. Btw I need a bleach.
Add Comment