Re: Eu 4.2.0 Beta?

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

Features I like about C++:

  • The ability to set constants in routines rather than only variables.
  • exceptions
  • full classes

Phix has all three, see below for my thoughts re classes.

SDPringle said...
  • operator overloading (need classes for this)

From operator overloading, comes the ability to create huge integers for cryptography.

Not a fan, and not sure what the connection is (in general) with huge integers. Plus whenever I've messed with cryptography it seems to be the other way round, in that I have to explicitly and frequently and_bits(x,#FFFFFFFF) to discard the high bits that plain C does without giving you any choice, change signs, etc.

SDPringle said...
  • delete should be something that not only calls the destructor but takes the passed variable out of scope at the point in the routine it is called.

not the delete() builtin itself, but I've been changing things like IupDestroy() into functions that return NULL(s), eg ih = IupDestroy(ih) as a way to prevent accidental use of ih after it has been destroyed.

SDPringle said...
  • an interpreter that wont mess up when I modify the length of a sequence I am iterating over. I get an index error if I remove an element.
for i = 1 to length(s) do 
end for 

My go-to solution for that is

for i = length(s) to 1 by -1 do 
end for 

Regarding classes/structs, I'm not finding them particularly useful. In fact I've just translated some OOP code, https://rosettacode.org/wiki/Red_black_tree_sort (Not the F# entry, which is as uttery fascinating as it is utterly indecipherable), and found it littered with code duplication such as (but much bugger chunks):

if (condition) { 
   thing.right = ... 
} else { 
   thing.left = ... 
} 

Whereas using sequences and indices lends itself quite naturally to far less code duplication:

integer d = iff(condition?LEFT:RIGHT) 
thing[d] = ... 

There are of course (a rare few) cases where classes/structs shine, I'm just saying they ain't no panacea.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu