LINK syntax

From ASCEND
Jump to navigation Jump to search
This page documents an experimental feature. Please tell us if you experience any problems.

This code was implemented by User:DanteStroe as part of GSOC2009, and has recently (Feb 2012) been merged into trunk (changeset 3923 through changeset 3931), although further testing is definitely still required. With these additions, the ASCEND now supports certain semantic object associations now. Additional logic is required to process these associations and make them useful in solvers, and and so on.

The existing associations

  • ARE_THE_SAME-- merge two existing instances recursively, resulting in one object with two names.
  • ARE_ALIKE-- keep the formal types of a list of instances identical, which prevents the user from doing dumb things and enables them to avoid writing most IS_REFINED_TO statements.
  • ALIASES-- define a new name by pointing at an existing instance, usually to assemble an array or expose a part buried in a lower-level model.

The proposed associations extensions

Syntax:

  • Declarative section: LINK( 'key', comma-separated-list-of-names);
  • Methods section: LINK(as-above); UNLINK(as-above);

Semantics:

  • Each MODEL instance gets a link table listing the links defined locally (with methods).
  • The LINKS defined in the declarative section are fixed and are stored in a link table as part of the TypeDescription.
  • The elements defined in the methods may be added and removed by running methods or API (user-interface) calls.
  • Redundant entries (identical key and namelist) are ignored with warning.
  • Conflicting declarative entries invalidate the typedescription.
  • Any instance name (subarrays, atoms, subatomics, relations, models, etc) are allowed in list-of-names.
  • Only symbol_constants and symbol literals (single quoted) are allowed as keys.
  • A link which is defined in a method and later redefined in a type refinement as a declarative link is allowed. A instantiation warning is generated and the declarative link semantics wins.
  • There is no way to make a declarative "down-in" link (link appear in another model scope).
  • There is no guarantee that the names in namelist exist, but user many turn on compiler options that generate warnings or compilation errors if the names cannot be resolved to instances.
  • There may be a link instance cache table (one for both declarative and method links). Any compiler action will invalidate the contents of this table.
  • UNLINK is not declaratively allowed. However, a specially recognized key LINK('ignore', target); will have the same effect for agents using the standard query routines: any link which is the target of an in-scope ignore link will be filtered out before any result is returned.
  • Links, thus, have labels like relations. The system will generate them if the user does not.
  • link label syntax is like relation label syntax, but links do not appear as model instance children internally except for name exclusion purposes-- they are really typedesc level info.

API functionality (initial) design

Invalid language.

You need to specify a language like this: <source lang="html">...</source>

Supported languages for syntax highlighting:

a4c, abap, abc, abnf, actionscript, ada, agda, alan, algol, ampl, amtrix, applescript, arc, arm, as400cl, ascend, asciidoc, asp, aspect, assembler, ats, autohotkey, autoit, avenue, awk, ballerina, bat, bbcode, bcpl, bibtex, biferno, bison, blitzbasic, bms, bnf, boo, c, carbon, ceylon, charmm, chill, chpl, clean, clearbasic, clipper, clojure, clp, cmake, cobol, coffeescript, coldfusion, conf, cpp2, critic, crk, crystal, cs_block_regex, csharp, css, d, dart, delphi, diff, dockerfile, dts, dylan, ebnf, ebnf2, eiffel, elixir, elm, email, erb, erlang, euphoria, exapunks, excel, express, factor, fame, fasm, felix, fish, fortran77, fortran90, frink, fsharp, fstab, fx, gambas, gdb, gdscript, go, graphviz, haml, hare, haskell, haxe, hcl, html, httpd, hugo, icon, idl, idlang, inc_luatex, informix, ini, innosetup, interlis, io, jam, jasmin, java, javascript, js_regex, json, jsp, jsx, julia, kotlin, ldif, less, lhs, lilypond, limbo, lindenscript, lisp, logtalk, lotos, lotus, lua, luban, makefile, maple, markdown, matlab, maya, mercury, meson, miranda, mod2, mod3, modelica, moon, ms, msl, mssql, mxml, n3, nasal, nbc, nemerle, netrexx, nginx, nice, nim, nix, nsis, nxc, oberon, objc, ocaml, octave, oorexx, org, os, oz, paradox, pas, pdf, perl, php, pike, pl1, plperl, plpython, pltcl, po, polygen, pony, pov, powershell, pro, progress, ps, psl, pure, purebasic, purescript, pyrex, python, q, qmake, qml, qu, r, rebol, rego, rexx, rnc, rpg, rpl, rst, ruby, rust, s, sam, sas, scad, scala, scilab, scss, shellscript, slim, small, smalltalk, sml, snmp, snobol, solidity, spec, spn, sql, squirrel, styl, svg, swift, sybase, tcl, tcsh, terraform, tex, toml, tsql, tsx, ttcn3, txt, typescript, upc, vala, vb, verilog, vhd, vimscript, vue, wat, whiley, wren, xml, xpp, yaiff, yaml, yaml_ansible, yang, zig, znn

See also