Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Grumm18243yNot 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. -
Voxera113883yExecute 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. -
Voxera113883y@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. -
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. -
Voxera113883y@lbfalvy reactive is how most functional languages manages performance, like f#, ocaml and haskel.
Think its called memoization also.
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?
question
language design
probably stupid