Coder Social home page Coder Social logo

Comments (2)

thisismypassport avatar thisismypassport commented on May 29, 2024

About the bug - yeah, it's the same issue as in #38 - I'll probably fix it by avoiding doing const replacement in focus-chars mode if the result is longer than the original tokens (though there are edge cases relating to const vars and to the possibility that even though parts of an expression are longer in constant form, the whole expression is shorter in constant form)

About the feature - hmm... So far I never adding tokens as part of minification, and I'm not sure that would be expected, even though --focus-tokens isn't provided. Maybe under some kind of --ignore-tokens option?
Do you know other such save-chars-at-the-cost-of-tokens tricks?

from shrinko8.

pancelor avatar pancelor commented on May 29, 2024

avoiding doing const replacement in focus-chars mode if the result is longer than the original tokens

Perfect, focus-chars-only is exactly what I would expect here

Oh, true=>0<1 adds extra tokens! very true and not good; I didn't even think about that haha (I've been in character-counting mode for the last few weeks). maybe only do this replacement iff the user asked for --focus-chars but did not ask for --focus-tokens? bah, it feels like a gross mess that users wouldn't be able to predict.

An alternate idea might be a new pause/unpause directive; something like: a=--[[shrinko8-pause]]0<1--[[shrinko8-unpause]]. Some sort of fined-grain control like this, although this exact suggestion feels a bit lacking, since it would only(?) work to prevent constant inlining...

> Do you know other such save-chars-at-the-cost-of-tokens tricks?

This was a fun exercise to think through! Here's a few I came up with just now:

1

if(not x) => if(x==a) saves one character, if a is unassigned/nil and the programmer is intending to only check for nil (i.e. they know x won't be false)

2

any output of my constant companion tool, e.g. replacing 0x6000 with ◆-♥, or replacing 0x7fff.ffff with 1/0. Or replacing 0xffff.ffff with ~0

3

I just thought up this toy example, probably not useful to you tho:

--28 tokens, 55 chars
function f(x) return x*2*3*4*5*6*7 end
a=f(10)
b=f(20)
--30 tokens, 33 chars
a=10*2*3*4*5*6*7
b=20*2*3*4*5*6*7

4

I suppose the tweetcart standard of using ::_::cls() flip()goto _ instead of using function _draw() end is another example (even when using the p8scii version of flip()cls())

5

similar to 3 but maybe more useful for shrinko8: creating an alias for an often-used variable or constant: u=unpack ... x=u(c) ... y=u(c) or e=128 .... rect(0,0,e,e) ...

from shrinko8.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.