﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
3853	Clean up OpenModelica base libraries	Rüdiger Franke	Martin Sjölund	"OpenModelica uses its own language and base libraries. Sometimes they appear grown arbitrarily instead of thoroughly designed. This costs a lot of time for looking up and finding out the right functions. Development time could be reduced and code quality increased if there were more common conventions. See three examples for lists, arrays and strings below.

Everyone can remember basic list operations, like `map` and `fold`:
{{{#!mo
  List.fold(List.map(outLocal, BackendVariable.varCref), BaseHashSet.add, HashSet.emptyHashSet());
}}}
But OpenModelica works more efficient if people state:
{{{#!mo
  List.applyAndFold(outLocal, BaseHashSet.add, BackendVariable.varCref, HashSet.emptyHashSet());
}}}
See: [changeset:9027e889/OMCompiler]. Can't combined functions like `applyAndFold` be hidden from the public interface and used by the translator automatically?

Here is an array example from SimCodeUtil.mo:
{{{#!mo
  Dangerous.arrayUpdateNoBoundsChecking(simVars, Integer(index),
     simVar::Dangerous.arrayGetNoBoundsChecking(simVars, Integer(index)));
}}}
Everyone could immediately grasp what this does if it was formulated like:
{{{#!mo
  simVars[index] := simVar :: simVars[index];
}}}
Does it really pay off in the high-level language MetaModelica to skip the bounds check?

Last but not least strings. One commonly wants to generate a string representation of an object, e.g. for debug logging. Programming languages typically offerer a common concept that applies everywhere, like `object.ToString()` or `to_string(object)`. 

OpenModelica sometimes uses the concept of appending `String` to the type name and starting with lower case, like `intString` or `realString`. This concept is also used in `BackendDump.mo`, e.g. for `BackendDump.equationString` or `BackendDump.timeEventString`. 

But there are many other functions that use a different naming that one hardly can remember, mostly in DAEDump.mo, prepending `dump` or appending `Str` instead of `String` or inventing some abbreviations, like:
{{{
  DAEDump.dumpOperatorString       --  operatorString
  DAEDump.dumpExtDeclStr           --  externalDeclString
  DAEDump.derivativeCondStr        --  derivativeCondString
}}}
It helped a lot if a common concept was used everywhere."	task	new	high	2.0.0	MetaModelica				Henning Kiel Per Östlund Peter Fritzson
