F3XTeam / RBX-Try-Library

A library for controlling the flow of error-prone, interdependent functions.
12 stars 3 forks source link

Optimize TryLibrary.lua #2

Closed Validark closed 7 years ago

Validark commented 7 years ago

And, it's shorter :D

Note: Didn't change actual functionality

Validark commented 7 years ago

I've integrated this module into RoStrap, which is available here, meaning users can install it directly using the plugin. If F3X requests that it be removed, I will remove it.

Validark commented 7 years ago

Feedback? Suggestions?

GigsD4X commented 7 years ago

This is great! Just got back from finishing a massive project over the past 2 weeks, will review these changes tomorrow 👍

One issue might be that comparing the metatables of potential attempt objects to Attempt could make attempts generated by different instances of the library incompatible. If the goal is to avoid a false positive when _IsAttempt happens to be in a returned, non-attempt table, perhaps we could move _IsAttempt into the metatable itself where it is less likely to conflict?

Validark commented 7 years ago

What scenario are you envisioning where a user generates an Attempt via Tryfrom the library, then calls the Attempt methods on that Attempt from a copy of the library or another version?

This just doesn't make sense to me, I don't see how that could be an issue. If people are using the prescribed method syntax, even if a user is for whatever stupid reason running 5 of the exact same library, there wouldn't be a conflict.

GigsD4X commented 7 years ago

This is possible in cases where an arbitrary system might come prepackaged with the library as a dependency in order to generate and return attempts that are intended to be used by any other arbitrary script (which may use a separate copy of the library to handle that returned attempt)

Validark commented 7 years ago

Again, still impossible if a person uses method syntax

GigsD4X commented 7 years ago

Merged these changes in 736af3be622eade2b0e7034d731f79c19f87fe08 for 2.0.0 🎉