Skip to content

Conversation

@DevYatsu
Copy link

Hey!

I’ve been experimenting with a basic time module, and while the goal was to build something practical, it also gave me the opportunity to reflect on some of the key features that I believe could significantly enhance the language at this stage of development.

This pull request is far from production-ready, it’s more of a conceptual proposal and discussion starter.

Key Observations and Suggestions

  1. Support for typed class arguments or instanceof
    One of the most urgent features, in my opinion, is the ability to either:
    • enforce type-safe method arguments within classes (preferably), or
    • introduce something like JavaScript’s instanceof.
    For example, in the Duration class, being able to write methods that safely accept another Duration instance would improve clarity and eliminate the need for manual runtime type checks — which feels at odds with the statically typed nature of the language.

  2. Proper error handling
    This is foundational. Right now, functions like elapsed() have to return nil on invalid input, but ideally, we’d want a way to raise and handle meaningful errors. I probably don’t need to justify this one 😄

  3. Static methods in classes
    Many languages support static methods for two main reasons:
    • Alternate constructors (from_seconds, from_millis, etc.)
    • Utility functions related to a class, but not tied to instance data
    While the first use case can often be handled via class inheritance, the second could bring real value. It’s not strictly necessary, but would definitely improve ergonomics.

  4. Operator overloading for class types
    Adding support for defining basic arithmetic and comparison operators would avoid a lot of boilerplate in classes like Duration, and make code involving them far more expressive and natural.

Looking forward to your thoughts! Just let me know which direction or feature you’d like me to focus on.

Thank you for work !

@Dishpit Dishpit self-requested a review May 30, 2025 19:00
Dishpit
Dishpit previously approved these changes May 30, 2025
stl/time.gem Outdated
@@ -0,0 +1,105 @@
module TIME
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we get this renamed Time to maintain consistency with Math? (HTTP is only capitalized due to it being an acronym)

stl/time.gem Outdated
@@ -0,0 +1,105 @@
module TIME
def now() int
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only other thing: can we shift this down to 2-space tabs?

@Dishpit
Copy link
Contributor

Dishpit commented May 30, 2025

i actually really like this! it's also a great foundational start to other libs in the future such as random numbers and cryptography, so it's a really solid addition to the codebase

just see the other comments re: formatting and i'll get this merged; static functions et al. can be added later and then this can be built out even further after that point. i'd say it's about as production-ready as it can be, given the current state of the language

@Dishpit
Copy link
Contributor

Dishpit commented May 30, 2025

ah, the build CI's failing

@DevYatsu
Copy link
Author

Let me check that out !

Dishpit
Dishpit previously approved these changes May 30, 2025
@DevYatsu
Copy link
Author

Wait, not done yet haha

@DevYatsu
Copy link
Author

I believe it should be fixed now

@DevYatsu
Copy link
Author

Okay, just moving an include statement out of a function and it's done :0

@Dishpit Dishpit self-requested a review May 30, 2025 23:03
@Dishpit Dishpit merged commit 9301a80 into SimuCorps:dev May 30, 2025
1 check passed
@DevYatsu DevYatsu mentioned this pull request May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants