Declarative programming is a paradigm of expressing the logic of a computer program or computation without explicit describing its control flow.
Questions tagged [declarative]
365 questions
6
votes
1 answer
Dictionary of tags in declarative SQLAlchemy?
I am working on a quite large code base that has been implemented using sqlalchemy.ext.declarative, and I need to add a dict-like property to one of the classes. What I need is the same as in this question, but in a declarative fashion. Can anyone…

Martin Blech
- 13,135
- 6
- 31
- 35
6
votes
9 answers
Best way to explain declarative fallacy in C++?
How might one craft a good explanation of why the following code is not correct, in that the author is attempting to write C++ code declaratively rather than procedurally?
const double NEWTONS_PER_POUND = 4.448;
int main()
{
double pounds,…

ybakos
- 8,152
- 7
- 46
- 74
6
votes
1 answer
Are there purely declarative, general purpose programming languages?
I've been researching declarative languages, and it seems like declarative is just an umbrella term for both logic and functional languages. Or am I wrong? Are there any general-purpose declarative programming languages that can't be classified as…

Matt
- 5,553
- 5
- 24
- 32
6
votes
2 answers
WF, WCF and Declarative Services (or: What does Microsoft mean by "declarative"?)
I've made this Community Wiki because some may think it's open to debate and others might think it's a question of using words to mean what they really mean (in other words, it's a matter of opinion whether it's a matter of opinion).
There's a…

Daniel Earwicker
- 114,894
- 38
- 205
- 284
6
votes
3 answers
OSGI Declarative Services (DS): What is a good way of using service component instances
I am just getting started with OSGI and Declarative Services (DS) using Equinox and Eclipse PDE.
I have 2 Bundles, A and B.
Bundle A exposes a component which is consumed by Bundle B. Both bundles also expose this service to the OSGI Service…

Christoph
- 3,980
- 2
- 40
- 41
6
votes
1 answer
prolog passing a function as a variable, how to add arguments?
I have this arbitrary function that I need to call many times with different variables.
btw, this is SWI-Prolog
perform(V1,V2,V3,Function,Result):-
%
% do little stuf.
%
Function(Arg1,Arg2,Result).
This gives a syntax error.
But…

Ihmahr
- 1,110
- 1
- 16
- 25
5
votes
9 answers
Tips for grokking declarative programming languages?
Question
As stated, have you any tips to help grok / understand / get-your-head-around declarative programming languages?
Or is it simply a case that you’ve to immerse yourself in the language and it’s syntax, until it seeps in, until you get that…

Binary Worrier
- 50,774
- 20
- 136
- 184
5
votes
2 answers
Is D's "static if" declarative or procedural?
Consider the following code:
static if (!is(MyStruct))
{
struct MyStruct
{
}
}
static if (is(MyStruct))
{
static assert(0);
}
My original understanding has been that the order of declarations (in global scope) does not matter in…

user541686
- 205,094
- 128
- 528
- 886
5
votes
2 answers
Testing a too general program
Suppose the correct definition of a predicate would be
len([],0).
len([_|T],N) :- len(T,X), N is X+1.
However, we end up with the following erroneous definition in stead.
len2([],0).
len2([_|T],N) :- len(T,X), ( N is X+1 ; N is X + 2, N =…

false
- 10,264
- 13
- 101
- 209
5
votes
1 answer
Can you catch errors in QML declaritive code?
I have a (declarative) line in my QML file which is logging an error and I want to catch it and log certain variables to try and figure out what's going on. The line is something like (contained in a Repeater hence the use of index):
a: ((n === -1)…

paxdiablo
- 854,327
- 234
- 1,573
- 1,953
5
votes
1 answer
Hide stages that are never run in declarative pipeline
I have a scripted pipeline that I want to port to declarative form. I used to have
// Stages used in developement after each single commit
stage('Build') {
}
stage('Unit Tests') {}
// Other stages only for developer
[...]
// Stages used in test…

Bob TheBuilder
- 79
- 1
- 3
5
votes
7 answers
Is there a declarative way to parse XML to Java objects?
I'm writing an import function of XML files to my Java application. I am using XOM to parse the XML files. The code for parsing the XML is not easy to understand, it is some hardcoded .getChild(3) and so on. It is hard to follow the code compared to…

Jonas
- 121,568
- 97
- 310
- 388
5
votes
1 answer
How to assert a negative fact in Pyke?
Let's say I have fact file:
code_in_git(a)
code_in_git(b)
code_in_git(c)
build_on_disk(a)
build_on_disk(c)
I want to assert the rule "if code_in_git($branch) and not build_on_disk($branch), create fact needs_build($branch)". How can I do that?

Kuroki Kaze
- 8,161
- 4
- 36
- 48
5
votes
5 answers
Are the implementation details of declarative languages inherently imperative
I'm reading 'Functional Programming' by Tomas Petricek & Jon Skeet and I understand the difference between declarative & imperative programming.
What I was wondering is how are the primitive operators & functions implemented, are declarative…

AwkwardCoder
- 24,893
- 27
- 82
- 152
5
votes
5 answers
On declarative programming in C++
Often I face the problem of mapping the parameter space of one API onto the parameter space of another one. Often I see this solved by nested nested nested ... switch statements.
And I was wondering if there would happen to be a library or a…

xtofl
- 40,723
- 12
- 105
- 192