Bots and Simulations > DNA Tools

Sanger

<< < (4/7) > >>

Numsgil:
Very nice.  I think the ternary operator is a little non intuitive, but I come from a C background, so maybe it's based on something in Perl?  I don't know how hard it would be, but something like:

if A && B || C then ... else ...

would mirror the DNA's structure and be more intuitive.

Also, I'm unfamiliar with Perl's && || operators.  Others probably are too.  Could you explain what they do?

Peter:
Well yes what do they, and will this be backward compatible. Dna->sanger

Gobo:

--- Quote from: Numsgil ---Very nice.  I think the ternary operator is a little non intuitive, but I come from a C background, so maybe it's based on something in Perl?  I don't know how hard it would be, but something like:

if A && B || C then ... else ...

would mirror the DNA's structure and be more intuitive.

Also, I'm unfamiliar with Perl's && || operators.  Others probably are too.  Could you explain what they do?
--- End quote ---
I'm going to introduce if later with the following syntax:

--- Code: ---if ( ... ) {
    ...
}
else {
    ...
}
--- End code ---
But there are some difficulties in implementation:
* Assigning to a variable in then and else which is used in the condition. This includes assigning to an expression, since expression may evaluate to an address of the variable used in the condition. Evaluation of the variable's address at compile time may be a complex task. Sometimes expression cannot be evaluated at the compile time at all (e. g. rnd(1000) ).
* Using rnd(...) in the condition.Perhaps I'll just forbid
* using rnd() in condition expression
* using variables modified inside then and else clauses in condition expression
* assigning to expressions inside then and elseNaturally if is already implemented, all I need to implement those checks, that is quite a bore.

Ternary conditional assignment operator is not met in Perl, though you can say in Perl:

--- Code: ---$a = 1 if $b == 0;
--- End code ---
Perhaps it is prettier, isn't it? I still can change to this syntax without much effort. What do you think?

&& and || work in Perl and Sanger as follows:
* a && b equals a if a is false (== 0 in Sanger's case), b otherwise (no matter if b is true or false)
* a || b equals a if a is true (!= 0 in Sanger's case), b otherwise (no matter if b is true or false)Since it is so, you may do conditional assignment an extra way:

--- Code: ---*.nrg > 20000 && .repro = 10;
--- End code ---
which is basically the same as

--- Code: ---.repro ?? *.nrg > 20000 = 10;
--- End code ---
But ternary conditional operator has an additional possibility to use this in condition. It refers to the value of the expression you assign. It is implemented with dup assembly operator.


--- Quote from: Peter ---Well yes what do they, and will this be backward compatible. Dna->sanger
--- End quote ---
Though I don't understand what you mean by 'backward compatible', I can assure you it won't make trouble. Sanger tracks boolean and integer contexts and modifies integer values met in boolean context accordingly (with sgn abs).

Peter:

--- Quote from: Gobo ---
--- Quote from: Peter ---Well yes what do they, and will this be backward compatible. Dna->sanger
--- End quote ---
Though I don't understand what you mean by 'backward compatible', I can assure you it won't make trouble. Sanger tracks boolean and integer contexts and modifies integer values met in boolean context accordingly (with sgn abs).

--- End quote ---
Ok, what I mean.

With sanger you do.
sangercode--->DB-dna
Can you also do
DB-dna--->sangercode

So having normal dna and with it making sanger.
Edit: I know at this very moment it isn't possible, but is it going to be.

Gobo:

--- Quote from: Peter ---With sanger you do.
sangercode--->DB-dna
Can you also do
DB-dna--->sangercode

So having normal dna and with it making sanger.
Edit: I know at this very moment it isn't possible, but is it going to be.
--- End quote ---
"Decompiling" is just another task. You cannot just take any DNA code and transform it into Sanger, since DNA code produced with Sanger is just a subset of all possible DNA code. I'm planning to write a tool, which would deobfuscate DNA code a little bit. But at the moment, I cannot advance because I don't understand how cond-start-else work exactly. I need to experiment with those.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version