lose the opportunity for "redirection" (Value.__Cat__ would
always be called).
"""
- # flatten the args and convert to tuple (not a generator)
- args = tuple(flatten(args))
+ # rely on Value.cast leaving Value/UserValue unmodified
+ args = [Value.cast(v) for v in flatten(args)]
# check if there are no arguments (zero-length Signal).
if len(args) == 0:
return _InternalCat(*args, src_loc_at=src_loc_at)
- # determine if the first is a UserValue.
- first, rest = args[0], args[1:]
- if not isinstance(args[0], UserValue):
- first = Value.cast(first) # ok to downcast to Value
- # all other arguments are safe to downcast to Value
- rest = map(Value.cast, rest)
# assume first item defines the "handling" for all others
+ first, rest = args[0], args[1:]
return first.__Cat__(*rest, src_loc_at=src_loc_at)
@final
def Repl(value, count, *, src_loc_at=0):
- if not isinstance(value, Value): # rare instances where integers are passed
- value = Value.cast(value)
+ value = Value.cast(value) # relies on Value/UserValue returned unmodified
return value.__Repl__(count, src_loc_at=src_loc_at)