Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>Yes, and if Python had a better type system, I could write a more concrete definition. Why don't you understand that?

I understand everything. It's you who doesn't understand. What I described is for ALL type systems in general. Not python types.

>Of course it's possible, the type system even supports almost everything that's necessary. You can already define what I want with a single fixed-size tuple of arbitrary size, you just can't do it with multiple ones. Why do you have this strange fixation on calling this "wrong" and "impossible"?

It's not a fixation. It's because I know what I'm talking about.

Look just prove it to me. Define the type signature for concat function that will concat two tuples with variadic parameters in TS.

Make sure the return value has the exact required shape. Additionally don't resort to using Any. Also define the intersection function as well. Again, Don't use any. Should be trivial if what you say is true.



> I understand everything. It's you who doesn't understand. What I described is for ALL type systems in general. Not python types.

Then why is what you're claiming to be impossible possible in Typescript? How can that be? Is the whole world wrong, aside from you?

> Look just prove it to me. Define the type signature for concat function that will concat two tuples with variadic parameters in TS.

You mean the one I already posted yesterday? https://www.typescriptlang.org/play?#code/C4TwDgpgBAglC8UDaA...

Or, if you prefer Python, run this:

  from typing import Tuple, TypeVar, TypeVarTuple, reveal_type

  T = TypeVar("T")
  Ts = TypeVarTuple("Ts")


  def concat(element: T, tup: Tuple[*Ts]) -> Tuple[T, *Ts]:
      return (element, *tup)

  element = "foo"
  tup = (True, 42)

  reveal_type(concat(element, tup))
You said it's impossible for the return type to be dependent on the input type. Why does Python disagree with you?


Let me address the one in python.

First off we are talking about concatenating tuples.

What you're doing here is called preppending an element to a tuple. Like come on man. Have you not been reading the examples I've been posting.

Your typescript example is relevant. But like I said it's an arbitrarily narrow thing. It's a special case. Typescript arbitrarily only supports only concat. Which is what I've been saying. It doesn't type level programming.

>Why does Python disagree with you?

There's no need to be a complete ass hole. Why does not being an ass hole disagree with you? First off your python example is completely wrong. Second off no point in saying snarky comments like that.


> Let me address the one in python.

> First off we are talking about concatenating tuples.

> What you're doing here is called preppending an element to a tuple. Like come on man. Have you not been reading the examples I've been posting.

I have no idea how you still do not understand what I am talking about.

My whole point is that Python doesn't support this. It has all the ingredients, it literally supports what you called impossible (having a function return a tuple type that's based on an arbitrary fixed-size input). Yes, the function doesn't support concatenating two tuples while being well-typed. That is what every single one of my messages was about. How do you read all my messages and not understand my basic argument?

And, please explain in great detail: if a typing system can handle prepending/appending an element to a tuple, what is the big difference to concatenating two fixed-size tuples? Why is one obviously possible, and one isn't? What is the fundamental difference?

> Your typescript example is relevant. But like I said it's an arbitrarily narrow thing. It's a special case. Typescript arbitrarily only supports only concat. Which is what I've been saying. It doesn't type level programming.

First off, you're wrong, it's not an arbitrarily narrow thing - Typescript does allow much more complex operations, the type system is literally Turing-complete.

But aside from that: I didn't say that it supports anything else. All I have been saying is: Typescript supports this thing, which Python does not. Why do you keep disagreeing and saying it's "wrong" and "impossible" when it does literally do what I've been telling you?

> There's no need to be a complete ass hole. Why does not being an ass hole disagree with you? First off your python example is completely wrong. Second off no point in saying snarky comments like that.

I have spent enough time trying to explain this to you. You're still fundamentally misunderstanding what I am talking about while acting like you know everything. You're either unable to understand it or a troll - it doesn't matter which it is.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: