You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
type[<Struct>]myClass(_myObj:int)=member_.myObj=_myObj
member_.myAct()=
System.Console.WriteLine(myObj)//I am not returning myObj now because I was simply doing whatever I can to let it be accessableletmyAct=letmyClass= myClass(5)
myClass.myAct()
myClass
As a programming language, we wanna provide a nice experience for people who wants to do it, now I propose how to provide this experience in my opinion by analysing these three cases
moving variable out of their scope might be putting it together with variables that belongs to 'other groups' of data, whether this classification has been expressed in code yet
you can access the locals only when you call the function, which is the way if they weren't static, but I want being able to mark local as static and access myObj via myAct.myObj
classes can't be nested for now in F#, writing classes for enclosure of data has been the way but I find it redundent, imagine you are building an UI window that has this button and that navigation bar these objects adds up it's a lot to write we can do it better
I propose we return locals in functions without people having to write it
People can use functions the way they are using, no breaking change
accessing locals in function is like 'peaking' what's inside, which should include variables they captured too
(An operator can support accessing what's in a function, for example myAct()~.myObj)
either implicitly export every local + capture or let people declare what locals are exported
(I say, ~let myObj = 5 for explicit export, once opt in implicit export is disabled, ~let static myObj = 5 makes myAct~.myObj possible : see how I didn't execute the function)
Sample :
letmyAct()=letstatic value =5letstatic myobj = Factory.Generate()
exe*(myobj)letanotherFunction()=letuseful= myAct.myobj
do_my_stuff (useful)
as you can see functions are now structured, you can confuse them with classes, but the exported context in these functions aren't available as a data structure in the function's return rather it's available as a language feature when you access the function and its return, of course the exports are stored in some data structure ultimately I say it's stored in immutable struct
I say it makes a good case for Haskell's approach of something safe to something safe & useful
how are you feeling after reading
//this wayletresult obj = Timestamp_.methodA obj
//or this way (regardless of the alternate choices of capturing methods in the last sample)//let result obj = Timestamp_(obj).methodAassert(Timestamp_(obj)=())
So you get the idea how objects and modules are unified
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Say you got a function
you want to access myObj
often as a first step towards alternative methods :
As a programming language, we wanna provide a nice experience for people who wants to do it, now I propose how to provide this experience in my opinion by analysing these three cases
I propose we return locals in functions without people having to write it
(An operator can support accessing what's in a function, for example
myAct()~.myObj
)(I say,
~let myObj = 5
for explicit export, once opt in implicit export is disabled,~let static myObj = 5
makesmyAct~.myObj
possible : see how I didn't execute the function)Sample :
as you can see functions are now structured, you can confuse them with classes, but the exported context in these functions aren't available as a data structure in the function's return rather it's available as a language feature when you access the function and its return, of course the exports are stored in some data structure ultimately I say it's stored in immutable struct
I say it makes a good case for Haskell's approach of something safe to something safe & useful
how are you feeling after reading
Sample 2 :
now you can use it
So you get the idea how objects and modules are unified
Beta Was this translation helpful? Give feedback.
All reactions