473,657 Members | 2,566 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A little quiz on macros

How would you implement a static dictionary with macros?

For example, the five lines

PL_FIND(MYDICT, HOUSE)
PL_FIND(MYDICT, AUTO)
PL_FIND(MYDICT, THIS_IS_NOT_IN_ THE_DICTIONARY)
PL_FIND(MYDICT, jhgjhguytuyhkgj hg)
PL_FIND(MYDICT, 3498fjkhdlkh340 98jhf)

should produce:

house_definitio n
auto_definition
symbol_not_foun d
symbol_not_foun d
symbol_not_foun d

Kiuhnm
May 10 '06 #1
13 2015
Kiuhnm <"kiuhnm03["@]yahoo.it> wrote:
How would you implement a static dictionary with macros?


I wouldn't. Learning stupid preprocessor tricks is a recipe for
disaster; you _will_ use them in production code, and that _will_ go
creatively and headache-inducingly wrong.

Next!

Richard
May 10 '06 #2
Richard Bos ha scritto:
I wouldn't. Learning stupid preprocessor tricks is a recipe for
disaster; you _will_ use them in production code, and that _will_ go
creatively and headache-inducingly wrong.


The C language is a trick. The C++ language is a trick. The assembly
language is a trick. A lever is a trick. What we see is a trick. And
then what? Should we limit our curiosity and creativity? I don't think so.
A little quiz is a little quiz, not a recipe for building strong
industrial applications. Anyway I was quite sure there was a standard
describing the C preprocessor.

Kiuhnm
May 10 '06 #3
On 2006-05-10, Kiuhnm <"kiuhnm03["@> wrote:
Richard Bos ha scritto:
I wouldn't. Learning stupid preprocessor tricks is a recipe for
disaster; you _will_ use them in production code, and that _will_ go
creatively and headache-inducingly wrong.


The C language is a trick. The C++ language is a trick. The assembly
language is a trick. A lever is a trick. What we see is a trick.


Sure they are. The difference is they're not stupid.
May 10 '06 #4
Jordan Abel ha scritto:
Sure they are. The difference is they're not stupid.


Then you must have solved the quiz and found it stupid.
Would you be so kind as to give me your answer?
I am very interested.

Kiuhnm
May 10 '06 #5
On Wed, 10 May 2006 20:28:08 +0200, Kiuhnm <"kiuhnm03["@]yahoo.it>
wrote:
Jordan Abel ha scritto:
Sure they are. The difference is they're not stupid.
Then you must have solved the quiz and found it stupid.


That doesn't follow. Here's the solution to your "quiz", repeated
here:

Quiz:How would you implement a static dictionary with macros?

Answer: I wouldn't.
Would you be so kind as to give me your answer?
I am very interested.

Kiuhnm


--
Al Balmer
Sun City, AZ
May 10 '06 #6
On 2006-05-10, Kiuhnm <"kiuhnm03["@> wrote:
Jordan Abel ha scritto:
Sure they are. The difference is they're not stupid.


Then you must have solved the quiz and found it stupid.
Would you be so kind as to give me your answer?
I am very interested.


I believe there is not an answer which would allow the "unknownsym bol"
responses. If there is, it requires excessively stupid contortions.
May 10 '06 #7
Al Balmer ha scritto:
Quiz:How would you implement a static dictionary with macros?

Answer: I wouldn't.


Wrong answer. Maybe you missed the word "How".

Kiuhnm
May 10 '06 #8
Jordan Abel ha scritto:
I believe there is not an answer which would allow the "unknownsym bol"
responses. If there is, it requires excessively stupid contortions.


Yep, very logical.

Kiuhnm
May 10 '06 #9
Kiuhnm <"kiuhnm03["@]yahoo.it> wrote:
Quiz:How would you implement a static dictionary with macros?

Answer: I wouldn't.
Wrong answer. Maybe you missed the word "How".


You missed the implied point that whomever is asking this question -
be it an instructor, a recruiter, or your boss - is either
intentionally wasting your time or an idiot, probably both. See what
your answer becomes when you unwittingly accept a job *maintaining*
this macro-implemented static dictionary.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cybers pace.org | don't, I need to know. Flames welcome.
May 11 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2128
by: DJ | last post by:
Here are my answers for quiz 3 - how well did I do? 1. If the statement: scanf("%d %d", &N1, &N2); returns the value 1, what do we know about what was read into the variables N1 and N2?
2
2637
by: Sketcher | last post by:
Hi, I am trying to create a quiz, Code is as follows: <html> <head> <title>Quiz</title> </head> <BODY> <Center><TABLE cellSpacing=3 cellPadding=0 border=0>
4
7462
by: DAL | last post by:
I want to build my kid a program that cycles through questions (using a label for the question), and lets him choose one of two radio buttons for the right answer. How do I get every set of questions and answers to cycle through until the last question? Also, how can I give him the score after the last question. Thank you in advance. DAL. P.S. As a beginner, I figured I couldn't pass up the chance to learn something new, and to practice...
6
2091
by: shror | last post by:
hi every body, i have a problem dealing with a quiz system in php. the idea is that am building a quiz system by giving a question and choices in radio buttons, and after selecting the answer the other question is loaded and in the final page a report is displayed showing all questions and the correct answers and the score but the problem here is that am not able to pass the answer of the first question to the second page question,...
1
1724
by: gts | last post by:
Hi, I've put together a little quiz using javascript. It doesn't actually keep score, it let's you keep answering the same question until you get it right. Most of the questions use multiple choice radio buttons and I have them working fine. One of the questions requires the user to enter a letter into 5 text input fields. The user has to enter A,B,C,D or E into each field. I wanted it to allow upper or lower case, so I used regular expressions...
12
1679
by: lkrzysiak | last post by:
I was traing to figure out an expression finding table names in sql query. Table name is known, for example 'table'. Below is sample code. This code should find last four strings ONLY. Other strings containing 'table' should be omitted. <?php $pattern = YOUR PROPOSAL $string = 'SELECT tableDupa,table1,otable FROM table,table ,
0
8397
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8310
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8827
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4315
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1957
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1620
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.