Re: Syntactic sugar

new topic     » goto parent     » topic index » view thread      » older message » newer message
begin said...

it should/could be an alias, so it will not break existing code. for anyone with some math background, the # and = make sense. just because some some scripters took an easy way out for comments, does not make it bad.

never the less, if it is not trivial and/or a lot of effort, then please forget the suggestion. it is not religious, but a lazy, readable way to say # instead of != (c/d/c# ...) or <> (pascal ...).

I'm not the final authority on these things, but I don't see it being a realistic possibility.

You're welcome to implement this yourself using the preprocessor. (I'm sure this code could be made more smarter.)

include std/io.e 
include std/search.e 
 
sequence cmd = command_line() 
sequence inFileName, outFileName 
 
for i = 3 to length( cmds ) do 
    switch cmd[i] do 
        case "-i" then 
            inFileName = cmd[i+1] 
        case "-o" then 
            outFileName = cmd[i+1] 
    end switch 
end for 
 
sequence lines = read_lines( inFileName ) 
 
for i = 1 to length( lines ) do 
 
  if search:begins( "#!", lines[i] ) then 
    -- skip shebang line 
    continue 
  end if 
 
  -- replace all instances of " # " with " != " 
  -- using spaces should prevent accidentally 
  -- replacing hex numbers (e.g. #80040023) 
 
  lines[i] = match_replace( " # ", lines[i], " != " ) 
 
end for 
 
write_lines( outFileName, lines ) 

-Greg

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu