Thanks @mashingan. My intention is to bring up a point (that popped up in an earlier post that I can't find) in which @araq and others that I can't remember, were talking about flexing out the restrictions, to allow duplication of either field labels or field names, when used in the case discrimination block for object variants. I could not find the post to append this case though.
In fact I made my example short enough for the forum, but I was trying to reduce a longer set of object types that looks like your first workaround, into a single object variant. Nesting objects is for sure what works since the 80's and 90's (i.e. I used it a lot in Turbo Pascal). The issue is that then you require double indexing like pointA.cyl.phi, instead of something like polarA.phi, but I can live with that. Your second workaround is kind of cumbersome due to the need of exceptions, but i'll explore more about such approach. It gave me some enlightenment in an operator overload like x= (I didn't know you could use a proc name with it, and that's a nice feature. What I'm trying to do, is to merge a large group of coordinate systems (not only 3D but from 1-D to N-D) into a single one, while exploring the possibilities in Nim, and that's how I got stuck. So it gets larger and larger as you start implementing (I have not yet, but a good initial type definition is the clue for a nice and intuitive library). Here the idea, still in its infancy: type #=========================================================================================================================================== # COORDINATE SYSTEM NOTATION RULE DIM BUs PRINT ($) (ARGUMENTS) NOTES #=========================================================================================================================================== CoordinateSystem* = enum csC1D, # Cartesian 1-D or Line Number __ RHR __ 1-D __ L __ (x) _________________ (x) ____________________ [ ] csC2D, # Cartesian 2-D or Polar ________ RHR __ 2-D __ LL __ (x, y) ______________ (x, y) _________________ [ ] csC3D, # Cartesian 3-D _________________ RHR __ 3-D __ LLL __ (x, y, z) ___________ (x, y, z) ______________ [ ] csCar, # Cartesian N-D _________________ RHR __ N-D __ L-L __ (x0, x1,... xN-1) ___ (x[0] .. x[n-1]) _______ [ x0=x, x1=y, x2=z ] csPol, # Polar _________________________ RHR __ 2-D __ LA __ (r, φ) ______________ (r, phi) _______________ [ φ=azimuthal_a ] csCyl, # Cylindrical ___________________ RHR __ 3-D __ LAL __ (r, φ, z) ___________ (r, phi, z) ____________ [ φ=azimuthal_a ] csSph, # Spherical _____________________ RHR __ 3-D __ LAA __ (ρ, θ, φ) ___________ (rho, theta, phi) ______ [ θ=polar_a, φ=azimuthal_a ] #[not defined (yet) # Orthogonal 2-D candidates csLin, # Line Number ___________________ RHR __ 1-D __ L __ (x) _________________ (x) ____________________ [ csLin=csC1D ] csPla, # Planar ________________________ RHR __ 2-D __ LL __ (x, y) ______________ (x, y) _________________ [ csPla=csC2D ] csEuc, # Euclidean _____________________ __ __ __ ____________________ csOrt, # Orthogonal ____________________ __ __ __ ____________________ csCur, # Curvilinear ___________________ __ __ __ ____________________ csHSp, # Hyperspherical ________________ __ __ __ ____________________ csPar, # Parabolic 2-D _________________ __ __ __ ____________________ csEll, # Elliptic 2-D __________________ __ __ __ ____________________ cs1CB, # One Center Bipolar ____________ __ 2-D __ LA __ (σ, τ) ______________ (sigma, tau) cs2CB, # Two Center Bipolar ____________ __ 2-D __ LL __ (r1, r2) ____________ (r1, r2) csBAn, # Biangular _____________________ __ 2-D __ AA __ (θ1, θ2) ____________ (thheta1, thheta2) csLoP, # Logaritmic Polar ______________ __ 2-D __ LA __ (ρ, θ) ______________ (rho, theta) csHom, # Homogeneous ___________________ __ 3-D __ LLL __ (x : y : z) _________ (x, y, z) csGeo, # Geographic or Geodesic ________ __ 3-D __ AAL __ (φ, λ, h) ___________ (phi, lambda, h) or (lat, lon, ele) csHor, # Celestial Horizontal __________ __ 2-D __ AA __ (a, A) ______________ (al, az) cdEqu, # Celestial Equatorial __________ __ 2-D __ AA __ (δ, α) ______________ (delta, alpha) csEcl, # Celestial Ecliptic ____________ __ 2-D __ AA __ (β, λ) ______________ (beta, lambda) csGal, # Celestial Galactic ____________ __ 2-D __ AA __ (b, l) ______________ (b, l) csSup # Celestial Supergalactic _______ __ 2-D __ AA __ (SGB, SGL) __________ (sgb, sgl) ]# csErr # Used if a wrong parameter count for the selected Coordinate System was entered #=========================================================================================================================================== Run