A macro in computer science is a rule or pattern that specifies how a certain input sequence (often a sequence of characters) should be mapped to a replacement output sequence (also often a sequence of characters) according to a defined procedure. Do not use this tag for questions regarding ...
2
votes
0answers
21 views
-3
votes
0answers
38 views
Group of commandbuttons with unique codes takes time to execute [on hold]
Issue: the workflow takes time and has caused some runtime errors. Would like to know if excess junk can be cleared and all codes can be streamlined.
Below is the context to each command buttons ...
0
votes
0answers
16 views
Interpreter for an assembly language with variadic instructions
I am currently implementing a virtual machine that runs a programming language similar to assembly. The difference is that an instruction in this language can have any number of operands. and the ...
1
vote
0answers
17 views
Implementation of catch test framework in Racket
As an exercise in learning how to use Racket macros I decided to implement a subset of the features in the catch test framework for C++. In particular the catch test framework has a unique feature ...
3
votes
1answer
71 views
Comparing two lists under 6 columns with 32000 rows in excel vba using dictionary
I need to import 2 .s19 files to excel and then Compare across 6 Columns in Excel and store the output to a txt file. I have my data from column A to F. My current program doesn't store the data using ...
4
votes
1answer
29 views
Saving the values of all variabled declared in a block
Often when running exprimental code to empirically investigate an algorithm, you tweak a parameter, then rerun the code, and generate a bunch of saved models for various parameters.
To make sure I ...
2
votes
0answers
33 views
VBA - Cycles through a table to find the cheapest bearing that passes
I have written several VBA macros to run on an excel spreadsheet. Inputs are entered into a table and then the macro is run; it cycles through a table of Bearings (in price ascending order) and ...
6
votes
2answers
78 views
VBA macro - searches through a filtered table, stops when entry passes criteria
I have written several subs which are then called from a main sub. Individual subs run very quickly, most are instantaneous (the DoFind sub takes a few seconds to run due to the large amounts of data ...
14
votes
3answers
937 views
On-the-fly destructors
Due to my needing to use C libraries inside C++, I kept finding myself wanting to be able to ensure that the free function got called, even if an exception got ...
5
votes
2answers
59 views
Retrieve value from a formula in cells into different merged cells and retrieved value can be edited
I have created this macro and having a small issue. I am very new to this VBA and did this with experts’ guides by googling it. I am creating an excel form for a work purpose at work. The Excel form ...
6
votes
3answers
68 views
Four versions of a database-creation function with different error handling
I'm starting a new, small C project and would like to have the safest, cleanest and shortest error handling code possible.
Here is a comparison of different ways to handle errors in the same C ...
4
votes
2answers
41 views
Error-checking macro to jump to specified label given a failing statement
I'm starting a new C projet and I want to have the cleanest and shortest error checking code possible.
To that aim, I often use two things :
functions return 0, ...
1
vote
1answer
44 views
Finding and deleting a certain word
I have a working macro that finds a specific word and deletes the whole text. It finds the word "JOBSPECIALTYCODE" in the sheet, selects and deletes it, then moves to the next sheet. I just want to ...
3
votes
3answers
67 views
List(Of ) like operation in macro
NOTE: I previously asked this question in Stack Overflow and got pointed here.
I have a macro that I am trying to get running a little more quickly. The intent of the macro is to merge multiple files ...
2
votes
1answer
39 views
Once-only macro
I have been learning common lisp and am a newbie, using the great book Practical Common Lisp. There is a once-only macro in the book that I spent a lot of time figuring out how it works. Even after I ...
2
votes
2answers
63 views
A stack optimized for filter queries, written in the C++ preprocessor
Given a stack with N elements and a query Q, we need to find all elements of stack for which ...
0
votes
0answers
49 views
Comparing two integers without logical, relational or bitwise operators - followup
Requirement:
Compare the input numbers (granted to be non-negative) without logical, relational or bitwise operators and no if/else statement or ...
4
votes
1answer
30 views
Introduce bindings for macro user
I'm doing the Racket track on exercism.io and solved the grains exercise:
Write a program that calculates the number of grains of wheat on a chessboard given that the number on each square doubles.
...
2
votes
1answer
129 views
Mutable stack in Racket
I'm learning Racket and have implemented a mutable stack, which is just a bunch of wrappers around an underlying struct containing a size and buffer list (so it's ...
7
votes
6answers
894 views
Length of a C string, capped to some maximum
If I have a oneliner in C such as
size_t maxSizeOf(const char *s)
{
return strlen(s) > M_MAX_SIZE ? M_MAX_SIZE : strlen(s);
}
would it be better to have ...
2
votes
2answers
199 views
C program to generate Seed programs from statically defined Befunge code
My program takes static input, and then number crunches for a few hours. I am currently using Macros, but is there a better, more "user friendly" way to do this without losing on performance.
I have ...
14
votes
2answers
154 views
Formatted print without the need to specify type matching specifiers using _Generic
This code allows printing in C with a style similar to C++ ostream. By using _Generic() (see ...
3
votes
1answer
57 views
Scale-able API development with macro definitions
In a couple of months I'll be part of a large(ish) project, and there's good chances my team will be a lot bigger, with at least 2 programmers (probably 3) and some 3-5, or more, consumers of the API ...
3
votes
1answer
69 views
in-nest-sequence: sequence generator in Racket
in-nest-sequence is a sequence generator that takes a function and an initial value, and the return value of invoking the function on the current value is used as ...
6
votes
1answer
134 views
Const by default
Being a C++ developer, but also having been influenced by functional languages, I strongly believe that const should be the default for the vast majority of all ...
2
votes
2answers
59 views
C++ Minimalistic Unit Testing Library
I was looking for a unit testing library for C++, and I found many. Unfortunately, I decided I didn't want to use any of them. I decided to make my own.
This is the result. I made heavy use of the ...
6
votes
1answer
99 views
Unit test macro
I have written a couple of macros (? and ??) for performing unit tests, but I'm having some difficulty with modifying it, so I ...
4
votes
1answer
156 views
Generic vector implementation in C using macros
I while ago I experimented with macros in C and came up with the idea of implementing a generic vector library using macros.
This code uses the non standard typeof ...
9
votes
0answers
120 views
Suggesting “safe enum” class for ISO C
There are quite some questions and answers about how to make enum really type-safe and I didn't find a solution that ensures both type safety and valid values. So I ...
1
vote
0answers
48 views
Creating class method using macro to accept Visitator for each of their fields
I had a lot of classes that used a macro with listed fields. The macro was used to serialization, more like MSGPACK_DEFINE. I need a substitution of this mechanism, ...
7
votes
1answer
129 views
Validation macro
I would like a review of a Scala validation library I am writing. For now we can focus on the regular expression component.
The usage is described in RegexExample.scala
There is an outline of the ...
6
votes
3answers
231 views
Macro enabling Python style 'with' in C++
I am developing a simple macro that enables Python style 'with' in C++.
I have shamelessly prefixed the macro name with BOOST_ - primarily because there's a ...
11
votes
1answer
220 views
Macro to build type declaration
These are some macros to help build a traits class (for the parser/printer classes I am building).
Traits.h
...
7
votes
0answers
144 views
Autotools detect C++ language standard support
I have been updating my build tools to optionally use autotools (autoconfig/automake/libtool etc.).
As part of this change I have written a couple of M4 macros. This not being something I have done ...
5
votes
1answer
50 views
Autotools detect YAML library
I have been updating my build tools to optionally use autotools (autoconfig/automake/libtool etc.).
As part of this change I have written a couple of M4 macros. This not being something I have done ...
3
votes
1answer
30 views
Autotools pull in standard build system
I have been updating my build tools to optionally us autotools (autoconfig/automake/libtool etc.).
As part of this change I have written a couple of M4 macros. This not being something I have done ...
3
votes
3answers
297 views
Use of macros to aid visual parsing of SFINAE template metaprogramming
I've recently been introduced to SFINAE to solve the problem of unwanted promotion precedence.
i.e. I was hoping to catch integer types with Foo::Foo(long) and ...
3
votes
1answer
338 views
Error-handling #ifdefs for AFNetworking requests
I am using AFNetworking 1.4.3 to send and receive network messages in iOS. My application works slightly differently in DEBUG and RELEASE mode, so I need to use ...
4
votes
2answers
136 views
Efficient mechanism to generate operator overload functions
I'm attempting to tidy up a C++ framework (PyCXX).
One particular file contains ~400 lines of operator overload functions, which I've managed to reduce to the following:
...
12
votes
1answer
155 views
Lua bindings for FTGL (FreeType font rendering in OpenGL)
I wrote some Lua bindings for FTGL's C API. This works well enough, but I ended up with lots of macros, one for each Lua function signature. For example, LUD_NUMBER_NUMBER_TO_NUMBER creates a Lua ...
7
votes
2answers
2k views
A tuple unpacking macro that approximates Python elegance
Motivation
Although I love coding in C++, I sometimes yearn for the syntactic sugar of Python. C++11 has somewhat eased the pain by such beautiful analogies like this:
...
1
vote
1answer
77 views
11
votes
3answers
1k views
Validity of macro for printf() call in a corporate environment
I wrote this program:
#include <stdio.h>
#define printS for(i=0;s[i];i++){printf("%c",s[i]);}
int i;
char s[] = "Hello World!\n";
void main()
{
printS;
}
...
4
votes
3answers
242 views
Penney Game - mapping macros to strings
The SPOJ problem:
Given a 40 character string representing outcomes of 40 coin tosses,
find the frequency destribution of all the possible outcome triplets.
So, for string like : HHHH....40 Hs ,...
13
votes
2answers
1k views
Template vector struct in C11
This one review will be a little bit tricky: I was trying to implement a template Vector struct in C11. Of course, templates don't really exist in C11, so I used a ...
8
votes
2answers
2k views
Macro that interchanges 2 arguments
Define a macro swap(t, x, y) that interchanges two arguments of type t.(Block structure will help.)
The ideea is that a ...
7
votes
1answer
4k views
Variadic macro enum class “reflection” in C++11
I recently had the need of "reflecting" multiple enum class constructs in order to get their elements' names as std::string ...
4
votes
2answers
157 views
Macros to detect UTF-8
I'm working on a program that handles UTF-8 characters. I've made the following macros to detect UTF-8. I've tested them with a few thousand words and they seem to work.
I'll add another one to do ...
4
votes
1answer
406 views
AppleScript to close running processes
I've been trying to emulate MS Windows behavior on my OS X and close processes that do not have a window.
What I'd really like to do is "quit" the process on clicking the red "x" button. Instead, I'...
2
votes
0answers
83 views
`multiple-value-call` in Scheme
Common Lisp has a "special operator" called multiple-value-call, which does something similar to Scheme's call-with-values but ...