Compiler

Syndicate content 5 

As a developer, you have probably spent at least some time writing repetetive code. You may have even found yourself wishing you could generate the code programmatically. If this sounds familiar, this article is for you!

We'll start with an example. Note: the following examples use the %DynamicObject interface, which requires Caché 2016.2 or later. If you are unfamiliar with this class, check out the documentation here: Using JSON in Caché. It's really cool!

Last comment 22 November 2016
+ 15   0 7
1118

views

+ 15

rating

Class Queries in InterSystems Caché is a useful tool that separates SQL queries from Caché Object Script code. Basically, it works like this: suppose that you want to use the same SQL query with different arguments in several different places.In this case you can avoid code duplication by declaring the query body as a class query and then calling this query by name. This approach is also convenient for custom queries, in which the task of obtaining the next row is defined by a developer. Sounds interesting? Then read on!

Last comment 9 December 2016
+ 14   0 9
3863

views

+ 14

rating

This is a translation of the following article. Thanks @Evgeny Shvarov  for the help in translation.

Let's assume that you wrote a program that shows "Hello World!", for example:

  write "Hello, World!"

The program works and everyone is happy.

With time, however, your program becomes more complex, gets more features and you eventually need to show the same string in different languages. Moreover you don't know the number and names of these languages.

The spoiler below contains a description of how the task of multi-language localization is solved in Caché.

Last comment 20 May 2017
+ 8   0 1
383

views

+ 8

rating

In this article I would like to tell you about macros in InterSystems Caché. A macro is a symbolic name that is replaced with a set of instructions during compilation. A macro can “unfold” in various instruction sets each time it is called, depending on the parameters passed to it and activated scenarios. This can be both static code and the result of ObjectScript execution. Let's take a look at how you can use them in your application.

Last comment 24 July 2017
+ 8   0 5
1071

views

+ 8

rating

In my previous article, we reviewed possible use-cases for macros, so let’s now proceed to a more comprehensive example of macros usability. In this article we will design and build a logging system.

Logging system

Logging system is a useful tool for monitoring the work of an application that saves a lot of time during debugging and monitoring. Our system would consist of two parts:

  • Storage class (for log records)
  • Set of macros that automatically add a new record to the log

Last comment 24 March 2017
+ 8   3 9
957

views

+ 8

rating

Greetings! This article describes yet another simple way of creating installers for the solutions based on InterSystems Caché. The topic covers applications, which can be installed or completely removed from Caché with one action only. If you are still documenting installation instructions that have more than one step to do to install your application — it’s high time you automated this process. 

Last comment 10 May 2016
+ 5   0 6
1024

views

+ 5

rating

On the back of my recent post on writing bug-less code I wanted to raise a few suggestions (to ISC) that would help prevent certain types of bugs at compile time. I've probably missed a few, but these are the main ones in my mind. Please contribute more suggestions.

Btw, these also serve as potential gotchas for new COS developers.

Last comment 18 April 2017
+ 4   0 1
696

views

+ 4

rating

Here you have an easy way to write and execute COS code from your unix scripts. This way one does not need to write routines or even open Studio or Atelier. It can be an option for simple and small actions for instance things like installation tasks or compiling.

See sample bash script (compile.sh) to compile classes:

Last comment 14 October 2016
+ 4   0 3
479

views

+ 4

rating

The attached file contains an example of code generation using ObjectGenerators which builds a very simple homemade RuleEngine. 

Code generation is an excellent way of increasing performance moving run-time calculations to compile-time.

We could generate code creating routines or implemeting methods using ObjectGenerators. In this example we are using ObjectGenerators.

Update: Rule Engine is now on GitHub https://github.com/intersystems-ib/cache-iat-ruleengine

+ 4   0 1
0

comments

359

views

+ 4

rating

So another topic that has been of interest to a number of people since the beta was put up last week is in regard to Studio Hooks and Atelier. This requires a bit of background and then some discussion of how the architecture of Atelier necessitates some changes and then what our current thinking on the subject is.

Last comment 3 March 2016
+ 3   0 6
965

views

+ 3

rating

Hi all!

I'm developing a mini-framework to implement annotations in Cache. I want to support two kind of annotations: metadata and method decorators. I've got stuck trying to implement the second one.

Metadata

With metadata annotations I can add metadata to any kind of target. A target can be a method/classmethod, parameter, property and class.

For example:

Last answer 25 January 2017 Last comment 26 January 2017
+ 3   0 2
449

views

+ 3

rating

Due to a new project I'm getting involved inside %Installer stuff deeper than ever I'd be happy to. Most of it was pretty easy to get, thanks to documentation, articles and SAMPLES example, while I can't dig good solution for one problem.

Last answer 28 March 2017 Last comment 28 March 2017
+ 3   0 1
210

views

+ 3

rating

I have just imported our Ensemble project (not a really big one, like two man-years) into my MacBook Air  Ensemble 2016.3 instance to test many things (document model, etc.), Atelier among the others.

The "Production view" is not here, and I miss it.

The opening of Diagram Editor for BP is pretty hidden. I would even like having a switch, which would default to the Diagram Editor. 

Anytime I click on the Open Diagram Editor, it waits for a while, ten produces an error and only then I can see the diagram.

Last answer 6 December 2018
+ 1   0 3
0

comments

296

views

+ 1

rating

I'm looking at adding multilingual support to a couple of open source projects I'm working on. The solutions are already developed in CSP so I am not looking for alternative approaches.

I'm wondering what would be the best approach for CSP and separate JavaScript files.

Initially I was wondering if I should bake the default system language text at compile time, or provide the end user with a language selection option at run time.

I came across $$$TEXT reading the docs...

Last answer 11 May 2017 Last comment 12 September 2017
+ 1   0 1
268

views

+ 1

rating

When I try to compile through Atelier (Compile Project), I noticed that in compilation with error it returns this message 'Failed to read /api/atelier/v1/ ...':

No additional Atelier files to synchronize.
Compile failed: Failed to read /api/atelier/v1/ERP/action/compile?flags=ck
Compile failed: Failed to read /api/atelier/v1/ERP/action/compile?flags=ck
Compile failed: Failed to read /api/atelier/v1/ERP/action/compile?flags=ck
Compile failed: Failed to read /api/atelier/v1/ERP/action/compile?flags=ck

Last comment 24 July 2018
+ 1   0 4
0

answers

237

views

+ 1

rating

Using our cool new debugging extension for Visual Studio Code I'm trying to debug a CreateProjection method of a class, but when I compile it the work apparently gets done in one of the worker jobs, so my breakpoint never triggers.

Is there a compiler flag or qualifier to force the compilation to be done in-process rather than getting handed off to a worker job?

Last answer 2 October 2018 Last comment 4 October 2018
+ 1   0 3
199

views

+ 1

rating

The class %Compiler.UDL.TextServices arrived in 2015.1, bringing us methods for exporting a class in UDL format (i.e. looking just like we're used to seeing it in Studio), and importing a UDL format definition back into a namespace. Some source control tools including our Deltanji are now able to use UDL format, resulting in diffs that are easier to understand.

Last comment 1 February 2017
+ 1   0 1
147

views

+ 1

rating

I have classes A and B, B derived from A, A has method Abc.

From INT of class B I see that compiler copies implementation of Abc to class B, so that Abc exists both in A and B.

As result, when B invokes Abs, B.Abs() is executed instead of A.Abs(). In result debuger is not able to step into Abs and breakpoints in A.Abs never hit.

Why this happens and how can I avoid this?

Update:

OK, now I know the reason: compiler makes the copy if Abc has this line:

Last answer 12 April 2017 Last comment 12 April 2017
0   0 4
213

views

0

rating

"Help me, Obi Wan Kenobi"?

I’ve hit the wall. I’m a one person shop who wants to start developing Cache on a mac using Eclipse/Atelier, after using Studio for the last 5 years. I’ve installed the 1.1 beta plugin, watched 6 or 7 videos from the September conference, tried several times to work through the cheat sheets, only to have connection issues or compilation issues, so at this point, I’m feeling very frustrated. The videos were interesting, but generally didn’t work as tutorials for fundamental programming operations, for me.

Last answer 13 November 2017 Last comment 14 November 2017
0   0 1
163

views

0

rating

Here's my code (download):

Class Utils.Generators [ Abstract ]
{

ClassMethod B()
{
    s ^a = 1
}

ClassMethod A() [ CodeMode = objectgenerator, GenerateAfter = B, PlaceAfter = B ]
{
    k ^a
    do ..B()
}

Now, obviously for it to work I need method B compiled and ready to use before compiling method A().

I test it with the following code:

Last answer 10 April 2016 Last comment 10 April 2016
0   0 1
443

views

0

rating

In part of this post in 2016 @Eduard Lebedyuk asked if anyone knew what is meant by an "expanded class", as referred to in the text that appears when we run the ShowQualifiers classmethod of %SYSTEM.OBJ thus:

SAMPLES>DO $system.OBJ.ShowQualifiers()
...
            Name: /checkuptodate
    Description: Skip classes or expanded classes that are up-to-date.

Last answer 30 January 2018 Last comment 30 January 2018
0   0 3
174

views

0

rating

Is there a way to enumerate the compilation status of a package?    

currently after deployment we are doing something like this to validate a successful load and compile of classes:

successful_compilation_count=`grep -a "Compilation finished successfully" output.log | wc -l`
successful_load_count=`grep -a "Load finished successfully" output.log | wc -l`

is there a method to do this where it is a little bit more elegant/dynamic without having to maintain counts for comparison ?

Last answer 13 March 2018 Last comment 15 March 2018
0   0 4
160

views

0

rating

I wonder if you could help me? I have a regular cache class that accepts a variable number of arguments in one of the methods. It works fine so I decided to add a method to my web service to make the call to the cache class. I get a compile error on the web service with error#5130.

Here is the cache class

Last answer 20 April 2017
0   0 2
0

comments

372

views

0

rating

Hi community.

I want to create a custom list inheriting %ListOfDatatypes in order to implement some methods like Map, Filter, ForEach, but I have some questions.
Just to mention, I have already read the topic about DeclarativeCOS.

When I define a property like following, caché uses %Collection.ListOfDT or %Collection.ListOfObj, as it's shown in the documentation

Last answer 4 May 2018
0   0 2
0

comments

171

views

0

rating

I have the following problem:

  • There are several classes with method generators, which needs to be compiled during every compilation
  • I have "ckub" qualifiers enabled in studio
  • I don't want to remove "u" qualifier because I need it very much in another namespaces

So how do I force classes with method generators to recompile when "u" qualifier is present?

Last comment 15 July 2016
0   0 2
0

answers

522

views

0

rating