Git Product home page Git Product logo

guts's Issues

php5 compliance

  • namespace
  • class
    • abstract
    • extends
    • implements
    • method
    • property
    • scope
    • type hinting
  • interface
  • function

LIKE operator for preg_match

if str like /([a-z])/ into matches
   orig = matches[0]
   p     = matches[1]

And compiles to:

if ( preg_match("([a-z])", $str, $matches ) {
    $orig = $matches[0];
}

regex literal, ideas from Cindy

Cindy said:

有打算在字串或 regex 的 literal 裡面能塞複雜的 expression 嗎?
像是 perl 的 "... @{[ sin 5 ]}..." 或 ruby 的 "... #{ sine 5 } ... "

我記得在 C 裡面因為字串很單純, 頂多就 \ 能 escape 一個字, 所以 C 的 string literal 可以用 lexer 就認得出來
如果裡面還能塞 expression 的話, regex 就認不了了

(這邊的 regex 指的是 lexer ^^|)
就要寫入 context free grammar 裡面

javascript 的字串或 regex 都沒有變數 interpolation, 事情有簡化一點
perl 因為有 interpolation, 而且直接就塞簡單變數, 不需要 #{ }, 所以有 ambiguity 需要投票
/...$a[12].../ 可以解讀為 $a 的內容, 然後 [12] 或是 $a 陣列的 [12] 這個元素
嗯, 如果可以統一定成... 一定會 greedy
往後延伸, 或是一定要 #{$a[12]} 都可以避開 ambiguity
覺得 ruby (也是 coffeescript) 的 interpolation 比較好做. 雖然就總是要多寫 #{...}
用簡單變數的時候反而比原生 php 還長.. 不過 php 一整個是在亂做 orz

啊我看你的設計裡面變數什麼的好像都沒有 prefix, 那就不用煩惱這種事了, 反正一定不能用 php / perl 這種簡易 interpolate

那用 #{...} 好了, 這樣設計的語言還不少, 用起來比較熟悉...
ruby, coffeescript, sass 都是 #{...}
php 的 regex 是用函數做的, 而且主流有兩種.... (聽說全世界主流 regex 也就這兩種 XD) 如果不要做 =~ 而只有做 regex 的 literal 的話, 好處是比較靈活能套來路不明的 regex engine
如果做了 =~ 就相當於釘死要用哪一套了

Syntax and CoffeeScript

Hey there,

instead of inventing yet another syntax, couldn't it be possible to re-use coffeescript's syntax ?

edit: just noticed last commit was 3 months ago, guess the project's dead anyway

Proposal: Syntax

Would it be possible to have a syntax like this on future versions?

namespace Universe\World\LivingThings
  class Specie
    protected $soul

  class Human extends Specie
    private $name
    private $age
    __construct: ($name, $age) ->
      @$name = $name
      @$age = $age
      @$soul = 'some soul'
      @breathe()
    private breathe: -> echo 'breathing'
    protected blink: -> echo 'blinking'
    protected @think: -> echo 'thinking'

  final class Person extends Human
    __construct: ($name, $age) ->
      parent::__construct $name, $age
      parent::blink()
      @blink()
      Human::think()
      self::hair()
      static::hair()
    protected blink: -> echo 'also blinking'
    protected @hair: -> echo 'long'
    public greet: -> 'hello world'
    public @something: -> new \Universe\World\Things\Something()

namespace Universe\World\Things
  use Universe\World\SomeOtherThings\Another as AnotherThing
  final class Something
    public anotherThing: -> new AnotherThing()

namespace Universe\World\SomeOtherThings
  final class Another

use Universe\World\LivingThings\Person
echo (new Person('joe', 21))->greet()
print_r Human::something()->anotherThing()

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.