Rational argument for not defining string constant for empty string?

L

Lew

Stefan said:
Already today one can write:

#define HASHSIZE 51
#define HASHSIZE_ASSERTATIONS \
assert new java.math.BigInteger( HASHSIZE ).isProbablePrime( 999999 ); \
assert HASHSIZE >= 1; \
assert HASHSIZE <= 1000;

. I'd call this the »replace-comments-by-asserts refactor«.

I would really, really hope that first assertion fails. (I'm ignoring the
blend of C and Java syntax. I pretend that "#define" is really a 'private
static final ...')
However, the word »smallish« has a certain vagueness that

"Prime", however, does not.
can be resolved by a human given a certain application/context.
So my translation to »<= 1000« might not be appropriate.

Irrelevant, perhaps.
 
A

Arne Vajhøj

Sometimes I run Java code through a preprocessor.

For example, I write the file »Add.java« in the
directory »de/dclj/ram« as:

$include /java.gpp
$define VERSION slr@2009-08-29T17:35:33+02:00
$define SINCE slr@2007-08-30T01:17:50+02:00
HEADER
/**
REFERENCES */

@de.dclj.ram.meta.quality.Cleaned(2)
DECLARE(interface)< Domain>
{ public void add( final Domain value ); }

The preprocessor generates from this:

/* Copyright 2004-2010 Stefan Ram.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */

package de.dclj.ram;

/**

@version slr@2009-08-29T17:35:33+02:00
@since slr@2007-08-30T01:17:50+02:00
@see<a href="http://www.purl.org/stefan_ram/java/de/dclj/ram/Add.java">source code</a>
@see<a href="http://www.purl.org/stefan_ram/html/ram.jar/de/dclj/ram/Add.html">documentation</a>
@see "<a href='http://www.purl.org/stefan_ram/pub/ram-jar'>Library homepage</a> (Must be opened in a<i>new window</i>, outside of frames, to avoid a 403 status code.)" */

@de.dclj.ram.meta.quality.Cleaned(2)
@de.dclj.ram.meta.description.Copyright( "Copright 2004-2009 Stefan Ram" )
@de.dclj.ram.meta.description.TypePath( "de.dclj.ram.Add" )
@de.dclj.ram.meta.description.Cleared( "slr@2009-08-29T17:35:33+02:00" )
public interface Add /* de.dclj.ram.Add */< Domain>
{ public void add( final Domain value ); }

Thus, the preprocessor inserts some boilerplate and
derives the name of the type declared from the file
name.

Similar concepts has been seen before, but note that you are
halfway at creating a new language.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top