Redundant Variant
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 !
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 !
3 posts
• Page 1 of 1
Redundant Variant
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.
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?
-
Phil Last - Posts: 628
- Joined: Thu Jun 18, 2009 6:29 pm
- Location: Wessex
Re: Redundant Variant
I agree, please keep this feature.
- gil
- Posts: 71
- Joined: Mon Feb 15, 2010 12:42 am
Re: Redundant Variant
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.
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.
-
Richard|Dyalog - Posts: 44
- Joined: Thu Oct 02, 2008 11:11 am
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group