Thanks so much for the attention to this post , I appreciate that!
my use case is simple, I wanted to have subset of the language to use it to define model schema with less code possible.
my background is python and we used to have simple toml format for our schemas
model_name = "person"
name = "myname" (S) # (S) means string
age = 30 (I) # I means Integer
created_at = 1234566 (T) # T is time stamp / epoch
the previous schema definition is simple and into the point, simple toml, I don’t use have to use complex programming logic
but we needed a special parser for this to parse and create proper objects
I wanted to achieve same simplicity of schema using crystal by defining my own data types subset
alias I = Int32?
alias S = String
alias F = Float64?
alias T = TimeStamp?
and I wanted my models/schemas to be defined in terms of these subset
property url : URL = "blah blah"
property time : T = 1234567
property logs : S = "blah blah"
so I was thinking in my use case for a time / epoch it’s just an integer , so I wanted to define my type T / TimeStamp to act like integer directly
I can compare it with another timestamp , so I can use the operators <. >. … directly
and in the same time I don’t have to do something like
property time : T = T.new 1234567
I understand it’s kind of syntactic sugar, but I was wondering if there’s simple way to have it
In python you could do anythin with any datatype forinstance
In : class TestClass(int):
...: def __new__(cls, *args, **kwargs):
...: return super(TestClass, cls).__new__(cls, 5)
In : tc = TestClass()
In : tc == 5
In : tc == 6