Questions tagged [constants]

Constants in programming are definitions whose value is fixed throughout a program's execution. Literals in most languages are constants, for example. In referentially transparent programming styles, all definitions are constant.

0
votes
0answers
5 views

Bot Framework - Luis Dialog - Set the LuisModel attribute from Web.config

I am writing a chat bot in Microsoft Bot Framework based on LUIS. (This is my first time using LUIS). I have a basic LuisDialog class where I would like to set the LuisModel attribute. The problem is, ...
0
votes
1answer
44 views

Swift constants which one is better? [on hold]

I have two separate arguments for handling constants in swift. The single structure handles all the constants in the application. Here is a small snippet of the code and I need suggestions on which ...
0
votes
0answers
31 views

PHP is allowing me to redefine a constant within included file

How can this be happening? It defies the language specs. outer.php --------- <?php define("VALUE","OUTER"); echo "Outer = " . VALUE . "<br>\n"; include "inner.php"; echo "Outer = " . VALUE ....
2
votes
2answers
57 views

Why direct assignment of constant within Class.new code block does not work

Consider the following code: c1 = Class.new { ANSWER = 42 } #⇒ #<Class:0x00556c8fc09c60> < Object c1.constants #⇒ [] c1.new.class.constants #⇒ [] c1.new.singleton_class.constants #⇒ [] ...
1
vote
1answer
40 views

Can I #define a constant solutionwide within c# code without project settings?

I know this was aksed and answered a a couple of times e.g. Solution-wide #define, Is There anyway to #define Constant on a Solution Basis? and How to define a constant globally in C# (like DEBUG). ...
-2
votes
0answers
18 views

Java “cannot assign a value to final variable NUMBER” in for loop [duplicate]

So in my current program, I'm calculating dice rolls in short. My college assignment wanted me to follow the algorithm listen in the assignment to create a while loop, then do the same exact thing for ...
0
votes
1answer
40 views

Angular 2+ - How to mockup constant class used for environment variables

I was wondering if someone could help me on this topic, I'm typing down some unit tests regarding to some functionalities that are done depending on the environment that's running at the moment. ...
2
votes
2answers
45 views

How to convert a hash ref in one line to a constant in perl

I'm using Sphinx::Search. Is there is a easier way for this code example to convert a string to a constant? use Sphinx::Search; my $config = { x => 'SPH_MATCH_EXTENDED2', }; my $x = $config-...
-6
votes
0answers
39 views

I don't know how to do getter and setter for constants in eclipse? [closed]

Problem: A program is needed to take online orders for bakery products. The Bakery sells 4 different types of bakery goods: cookies, donuts, cakes and pies. The prices per item are as follows: Item ...
-5
votes
0answers
24 views

Permitted Xcode variables and constants [closed]

Are these valid names for variables or constants in Xcode :
0
votes
1answer
40 views

Save/load a keras model with constants

I have a Keras model where I'd like to add a constant to the predictions. After some googling, I've ended up with the following code, which does exactly what I want: import numpy as np from keras....
0
votes
0answers
67 views

g++ warning “defined but not used” on global const, depending on optimization flags

Consider the following: // headher h.h #pragma once namespace foo { const float c1 = 0.22; inline float f() { return c1; } const float c2 = f(); const float c3 = 0.33; } // source ...
-1
votes
2answers
69 views

Whats the best way to implement global constants in java between multiple public classes? [closed]

I've just started learning Java after getting the hang of C++, and I'm wondering if there is a way that I can have global constants the same way in C you can have a Header file with a list of ...
0
votes
0answers
16 views

constant and missing old header

My code : 'BOOL' CNetworkLibrary::CheckEdit(); // Anti Edit { bool m_Debugger = false; CCRC32 MyCRC32; MyCRC32.Initialize(); static const int counter = 0; const char* ...
0
votes
1answer
23 views

How to define multiple constants in config.js

I am trying to save some PIXIJS styles in a config.js file, so that I could reuse these style contants in other JavaScript files. Is it possible to define these multiple constants (fontFamily, ...
0
votes
0answers
11 views

How to reuse style constants from PIXIJS in the same config.js file

I am trying to save PIXIJS styles in a config.js file, so that I could reuse these style contants in other javascript files. For example I want to define this constant styleText in my config.js and to ...
-4
votes
1answer
16 views

Constant Base-url for Woocommerce

Hello i change a plugin create for Prestashop to Woocommerce, and i would Know if have a same constant _PS_BASE_URl__ ? I have see WP_SITEURL do it's work for woocomerce ?
0
votes
1answer
18 views

C# declaring public constants through console application

These are the 3 public constants (v,k,t) that I change directly through the program, but because the program is written for someone else I would like to have a console application that prompts the ...
0
votes
1answer
21 views

JavaScript Constants - Defining Multiple Functions

I've been trying to get multiple functions working in 1 const, but it either does not work (Uncaught SyntaxError: Unexpected identifier) or I'm missing something, and I hope someone can help. Why ...
1
vote
2answers
48 views

What exatly are char16_t and char32_t, and where can I find them?

I was looking for char16_t and char32_t, since I’m working with Unicode, and all I could find on the Web was they were inside uchar.h. I found said header inside the iOS SDK (not the macOS one, for ...
0
votes
1answer
12 views

IntelliJ IDEA: Extract Constant in javascript

I use Ctrl Alt C to extract constants in Java, but for Javascript, esp for React/ES6, I do not find the option to extract constant in IntellJ. Also checked the context menu, but it's not there. I ...
0
votes
2answers
64 views

Enumerating string constants with iota

The following example defines a series of port numbers starting at 3333 using iota. package main import ( "fmt" ) const ( FirstPort = iota+3333 SecondPort ThirdPort ) func main() { ...
0
votes
3answers
72 views

Need to calculate an average in C# from an Array

Hi everyone first time poster here, Just wanted to ask any C# experts out there for some help. I've been struggling with this for a while and just can't figure it out. Basically, I have an array from ...
1
vote
1answer
29 views

Constant variable even though it changes

Please consider this code after running pylint: ''' Test ''' i = 0 while i < 4: myvar = i i = i + 1 pylint reports: Constant name "myvar" doesn't conform to UPPER_CASE naming style (...
2
votes
2answers
47 views

Properly design project with many constants in C++

On our current project, we are currently having issues with the way we are handling constants. To try to sum it up, let's say we have different action types, defined as const std::string const std::...
0
votes
1answer
23 views

Can I use constant values in key value pair object in javascript [duplicate]

I would like to define a set of constants, which I then use the values of in another javascript object. I have the below example. This however doesn't seem to work when I am trying to use 0 as a key ...
0
votes
1answer
47 views

Eclipse - Wrong suggestion when extracting a constant with similar variable name

I'm using Eclipse Neon in java code, When I want to Extract Constant for example String value "subject" while having a variable name: String subject = "subject"; When Extracting Eclipse offers me ...
-1
votes
1answer
51 views

Issue with Switch Case using String Constants initialized from an Enum

I have a switch case in my code which has cases defined on String constants. If I initialize the String constants as String INACTIVE = "INACTIVE"; The switch case works fine. However, If ...
1
vote
0answers
12 views

Can an immediate 32 bit value be written as a four character constant in the GNU assembler?

On a x86 (32 bit) environment, I can push a 32 bit value onto the stack (intel syntax): push 0x576f7264 This 32 bit value is the hexadecimal representation of the (not null terminated) string Word. ...
0
votes
0answers
46 views

Final static field of Integer[] type can be changed [duplicate]

I have a Constants class, that has a static final field. I found out, that I can rewrite this field. public static final Integer[] THUMBS = {R.drawable.one, R.drawable.two}; In my code I make ...
0
votes
1answer
38 views

Why the phpinfo() function gives wrong result when one or more of the numerical constants bitwise values are passed as arguments?

I'm using PHP 7.2.8 I executed below code : <?php phpinfo(2 | 8); //Bitwise OR operator is used ?> Above code worked fine and give me the expected result. Then I tried to pass the ...
3
votes
1answer
57 views

Is it possible to pass constant parameters UPWARDS through module hierarchy in Verilog / SystemVerilog?

Assume you have a module at a low-level in your hierarchy that has a fairly complex parameter calculation. This parameter calculation can not be conveniently replicated in a higher-level module, ...
0
votes
2answers
35 views

How to make a Simulink model constant?

I have a model in Simulink (2018a) which has more models inside. So I have: parent.slx --> child.slx I want child.slx to execute only once in the whole simulation, so basically its output will be ...
1
vote
2answers
58 views

Pythonic Way to Define Status Constants

I wrote a function which could output three things: def getStatus(): if condition1: return "NormalStatus" elif condition2: return "ServerCompromised" elif condition3: ...
0
votes
0answers
30 views

Unexpected value in TYPE field in CallLog.Calls

I'm using a data set of Call Logs from Android phones and have started seeing unexpected values in the TYPE field, which indicates details about the direction of calls (Eg. Incoming, Outgoing, Missed, ...
0
votes
1answer
31 views

OpenCL CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE not consistent

I am trying to understand the value of CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, specifically for a RX Vega 56 GPU. My own program queries and outputs the following: CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE ...
0
votes
1answer
22 views

How to define constants in php and access it from all files without including the constants file (any thing like AppSettings in .Net)

I want define some constants and access those from any file without including any file in php. in the other word i search for any equivalent of Web.Config->AppSettings in C#
0
votes
2answers
41 views

Best way to store constants whether enums or database tables keeping internationalization in mind

I have lot of static/constant data which I want to store, this data is also related with each other. I can use lot enums referencing each other forming a tree or a graph. Or simply use tables or ...
-1
votes
3answers
44 views

Why DEFINE in PHP can accept random values?

Constants can't accept expressions that make calculations. Why can I declare DEFINE with random_int(1,4) and not get a fatal error? In this case, the value of the constant will be different every time ...
0
votes
0answers
22 views

Constants are undefined while testing using Enzyme + React Native + Jest

I want to unit test my React Native component with Enzyme and Jest. It is a QR Scanner that calls a function after a successful scan. This function communicates with the server and returns a response....
-1
votes
1answer
52 views

Nested constants in Rust

In Ruby, I can do this: module Settings module General SomeSetting = "Some value" end end puts Settings::General::SomeSetting; # => "Some value" How do I achieve the same thing in Rust? ...
0
votes
1answer
48 views

use asserts for debugging Modelica

In Modelica, one could define a protected final constant Boolean debug and then use that in an assert statement to print out some values while debugging, similar to the code shown below (or as seen on ...
3
votes
0answers
25 views

How to avoid the error thrown by the maxima function polynomialp?

Look at the following two sequences of two commands. They are the same up to the choice of variable a or z, but the version with a produces an error whereas the function with z does not. First run (...
0
votes
0answers
9 views

long list of predefined colors flagged by flycheck as unused and disables

I have a file colors.py with a list of 500+ predefined colors such as: WHITE = (255, 255, 255) BLUE = (0, 0, 255) etc. Now when I use from colors import * in some script, flycheck (through pylint?) ...
1
vote
1answer
30 views

Where update operators constants are in MongoDB Java driver?

I'm going to use mongo-java-driver-3.8.0 on my application and I just started studying the documentation to use it in a proper way. The class com.mongodb.QueryOperators has constants for the operators ...
1
vote
2answers
56 views

Using global constant or enums without specifying class names

I'm migrating a C program to C# that simply listens serial port and decodes incoming bytes to build the command packets. So I have some constant variables and typedefs in a header file named "protocol....
0
votes
1answer
45 views

iOS: How to get the #define from a Constant.h ObjC in a Swift File? [duplicate]

When I write this in the constant.h file: #define WS_PLANNING_INFORMATION "registrations/" It works when I call it from the Swift file. But if I write this in the constant.h file: #define ...
4
votes
1answer
61 views

Perl: constants and compile-time vs runtime hash lookups?

In Perl 5.26, constant-based hash lookups appear to be resolved at compile-time, not runtime. How can I enforce it to be resolved at runtime? Consider the following reduced testcase, boiled down from ...
1
vote
1answer
18 views

Adding a row-dependent value to each row

I have a 2D array containing the following numbers: A = [[1, 5, 9, 42], [20, 2, 71, 0], [2, 44, 4, 9]] I want to add a different constant value to each row without using loops. This value ...
0
votes
0answers
33 views

Magento Custom Constants class

What is the best practice to add constants class in Magento to define error codes and static strings to be used all over my code? Thanks.