Redundant Variant

APL-related discussions - a stream of APL consciousness.
Not sure where to start a discussion ? Here's the place to be
Forum rules
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !

Redundant Variant

Postby Phil Last on Thu Aug 15, 2019 10:58 pm

I've recently used ⎕JSON for the first time in an emulator that has to work back to 14.1 when 7159⌶ & 7060⌶ were introduced.

The way our emulators work the long-winded function for older interpreters is overwritten at startup by a shorter expression or a primitive if the interpreter version is greater than or equal to that in which the enhancement was introduced.

As we now have only ⎕JSON rather than the functionality split between the two i-beams I tried it on its own and find I need the variant ('Compact' 0) for export to give me formatted JSON equivalent to 0 1(7160⌶). Fortuitously or deliberately I find that its redundancy for import is ignored rather than triggering an error so that I can code an unconditional expression that serves for both purposes.

  • If it's deliberate then thank you very much for your foresight
  • If it's fortuitous can please it be put on record that it should be kept thus?
User avatar
Phil Last
 
Posts: 628
Joined: Thu Jun 18, 2009 6:29 pm
Location: Wessex

Re: Redundant Variant

Postby gil on Fri Aug 16, 2019 10:40 am

I agree, please keep this feature.
gil
 
Posts: 71
Joined: Mon Feb 15, 2010 12:42 am

Re: Redundant Variant

Postby Richard|Dyalog on Fri Aug 16, 2019 2:06 pm

It is deliberate, but I'll raise an issue to clarify the docs, and put in QA to ensure it remains so.

The thinking behind variant is this: it takes a function and modifies it so that it has different properties - for example, ⎕JSON produces "compact" JSON when it exports APL data, but you can change that by applying ('Compact' 0) to it using variant. The derived function you get from doing that can also be modified again and again, and ⎕JSON itself is conceptually just a variant of another function buried deep in the interpreter which has had ('Compact' 1) applied to it.

So, under this model, it cannot possibly be erroneous for you to set the 'Compact' variant option on JSON import because ⎕JSON has conceptually already had ('Compact' 1) applied to it.
User avatar
Richard|Dyalog
 
Posts: 44
Joined: Thu Oct 02, 2008 11:11 am


Return to APL Chat

Who is online

Users browsing this forum: No registered users and 1 guest