Re: Getting rid of varbrace

Daniel Jour <[email protected]>
Newsgroups gmane.lisp.clisp.devel
Message-ID <CACZHyTPhPdwgBkcN+PLoTbp-+WjB4pTmGNukNTp5Eyr_OqPB1Q@mail.gmail.com>
Hi Sam,

> we need either a comment or a thorough purge.
> I favor the latter because I want the CLISP sources to _look_ like
> regular C.

Me too. Though I got the impression from our discussions last year
that a full purge - due to the massive commit this would cause - is
not wanted. That's why I went the `#define var` way.


> Note that the purge can be done with a perl one-liner.

Yes, but bear in mind that the purge is only the first step.  Removing
var causes problems.  In the second patch of the original mail I only
corrected those which caused compile errors for my configuration.
There are possibly many more of them when looking through all the
code.  Examples:

A declaration cannot immediately follow an label. There are LOTS of
those errors. Example:

label:
  var type name;

I solved this like so:

label:;
  var type name;


> No, please add braces instead.

This might work in some cases, but most of the affected code is highly
"unstructured". If I could easily add braces without rewritting it,
then there wouldn't be labels and gotos but if, while and friends.

I tried to find more instances of those with:

find src -type f -name '*.d' -exec \
  pcregrep -MHno \
    '[[:alnum:]]+:([^:;{]|\n)*?var([^;]|\n)*+;' '{}' ';' \
    2>/dev/null \
  | sed 's_^src/_\x0src/_g' \
  | grep -z -v -F ': */' \
  | less

But this shows many false positives...


Another issue is conflicting definitions of the same variable. Example:

var type1 foo;
// some code
var type2 foo;

This is solved by renaming one of them, if possible. In two places, I
manually added braces (like varbrace would've done), specifically in
src/intlog.d, function I_logcount_I, the variables with the name (as
written in the source code) "x16". The issue is that "x16" might be
"#define" to something else, and I didn't exactly understood why and
when.


> Please either make a separate patch or tell me where the
unused var is.

I attached a patch with the small change (including an entry in the
changelog, just to be sure ;) )


> I will let Bruno decide on this.

Bruno, what do you think?

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

_______________________________________________
clisp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/clisp-devel
remove_unused_variable.patch (application/octet-stream, 1.1 KB)
# HG changeset patch
# User Daniel Jour <[email protected]>
# Date 1490300140 -3600
#      Thu Mar 23 21:15:40 2017 +0100
# Node ID 2bf1af7c25525b264405d361aa6759f1059f1438
# Parent  86e4c0dc1cfadf2ddb4a95c698d0105c1789c71f
remove unused variable "size" from src/array.d (make_bit_vector)

diff -r 86e4c0dc1cfa -r 2bf1af7c2552 src/ChangeLog
--- a/src/ChangeLog	Wed Mar 22 17:05:24 2017 -0400
+++ b/src/ChangeLog	Thu Mar 23 21:15:40 2017 +0100
@@ -1,3 +1,7 @@
+2017-03-23  Daniel Jour <[email protected]>
+
+	* src/array.d (make_bit_vector): Remove unused local variable "size".
+
 2017-03-22  Sam Steingold  <[email protected]>
 
 	* makemake.in (check-script): Add a test for -x raising an error.
diff -r 86e4c0dc1cfa -r 2bf1af7c2552 src/array.d
--- a/src/array.d	Wed Mar 22 17:05:24 2017 -0400
+++ b/src/array.d	Thu Mar 23 21:15:40 2017 +0100
@@ -5156,7 +5156,6 @@
 
 LISPFUNN(make_bit_vector,1)
 { /* (SYS::MAKE-BIT-VECTOR size) returns a Bit-Vector with size bits. */
-  var uintL size;
   if (!posfixnump(STACK_0)) {
    bad_size:
     /* STACK_0 = size, TYPE-ERROR slot DATUM */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.