fez
fez copied to clipboard
Functions returning objects or records
Hi,
I have been looking at implementing the Regex module. How would I go about returning objects? (ex: Match object, with .Success, .Groups, .Captures etc.)
Do I just return a map or a record?
A record might work. Depends on what data you need.
The type you return is effectively opaque to the caller as it will be passed to the member function as it's first parameter. I'd suggest you write a simple example. compile it and look at the .core file to see what it is doing.
Thanks, will give it a try
Sorry, been a bit busy!
Still having some trouble with this.
The core file seems to generate a get_<field-name>
function.
So using var.Groups in f# seems to generate
'System.Text.RegularExpressions.Match':get_Groups(#{'Captures' => [],'Groups' => [],'Length' => 0,'Success' => false,
'Value' => ''})
which does not exist
Using a record also results in a get_Groups({some, tuple, here})
Any pointers?
Yes you need to implement the function as generated as an erlang module in src On Fri, 30 Jun 2017 at 17:59, rascala [email protected] wrote:
Sorry, been a bit busy!
Still having some trouble with this. The core file seems to generate a get_
function. So using var.Groups in f# seems to generate 'System.Text.RegularExpressions.Match':get_Groups(#{'Captures' => [],'Groups' => [],'Length' => 0,'Success' => false, 'Value' => ''})
which does not exist
Using a record also results in a get_Groups({some, tuple, here})
Any pointers?
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/kjnilsson/fez/issues/18#issuecomment-312320363, or mute the thread https://github.com/notifications/unsubscribe-auth/ABIDlIAZSYNIR3GU8QFnaMVnLqeOAlm0ks5sJSmFgaJpZM4OC2jf .
You probably want to pull the latest changes As there are potential changes to how objects are constructed.
See this as an example.
https://github.com/kjnilsson/fez/blob/master/src/System.Lazy_1.erl
Thanks,
I have a very basic regex working(without global-match etc.), but its very ugly with different files for Capture/CaptureCollection/Group/GroupCollection/Match/Regex
types and respective get_<field>
s all over.
But it works! And returns captured groups and their values etc.
I will try to clean them up a bit, add more tests and add the match-options.
Wouldn't it be cleaner if all System.Text.RegularExpressions/* files were grouped into a separate directory? And maybe all these should be grouped into a lib/stdlib directory? So that src does not get cluttered?
Cool. It's fine to have them all in src. It's typical of erlang. Subdirectories add very little IMO. On Sun, 2 Jul 2017 at 15:18, rascala [email protected] wrote:
Thanks,
I have a very basic regex working(without global-match etc.), but its very ugly with different files for Capture/CaptureCollection/Group/GroupCollection/Match/Regex types and respective get_
s all over. But it works! And returns captured groups and their values etc. I will try to clean them up a bit, add more tests and add the match-options.
Wouldn't it be cleaner if all System.Text.RegularExpressions/* files were grouped into a separate directory? And maybe all these should be grouped into a lib/stdlib directory? So that src does not get cluttered?
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/kjnilsson/fez/issues/18#issuecomment-312494496, or mute the thread https://github.com/notifications/unsubscribe-auth/ABIDlCmYHP9NXCuysqC8pZjGoQuQtmm8ks5sJ6abgaJpZM4OC2jf .
@rascala I just made some significant changes to how functions and modules are generated which may affect the work you have in progress. I'd recommend you pull and check the .core files to see what modules and names are required.