Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Weird Tuple types that seem like they should be disallowed?

$
0
0

I noticed that some Tuple types that are parameterized by non-types exist, but seem useless. I wonder if they:

  1. May have instances at all?

  2. Should be disallowed?

Example:

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.5.4 (2021-03-11)
 _/ |\__'_|_|_|\__'_|  |
|__/                   |

julia> Tuple{1243} <: Tuple{Any}
true

julia> Tuple{(124310, 983724)} <: Tuple{Any}
true

It’s relevant that similar constructions are not permissible in function type signatures:

julia> function f(x::423)
       5
       end
ERROR: ArgumentError: invalid type for argument x in method definition for f at REPL[2]:1
Stacktrace:
 [1] top-level scope at REPL[2]:1
 [2] run_repl(::REPL.AbstractREPL, ::Any) at /build/julia/src/julia-1.5.4/usr/share/julia/stdlib/v1.5/REPL/src/REPL.jl:288

11 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795

Latest Images

Trending Articles



Latest Images